Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/202.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 可以用闹钟设定一个特定的日期吗?_Android_Setalarmclock - Fatal编程技术网

Android 可以用闹钟设定一个特定的日期吗?

Android 可以用闹钟设定一个特定的日期吗?,android,setalarmclock,Android,Setalarmclock,这是我设置闹钟的方式: //all this inside a onClickListener Calendar cal = Calendar.getInstance(); cal.set(Calendar.DAY_OF_MONTH, 30); cal.set(Calendar.MONTH, 8); cal.set(Calendar.YEAR, 2020); Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM); intent.putE

这是我设置闹钟的方式:

//all this inside a onClickListener
Calendar cal = Calendar.getInstance();
cal.set(Calendar.DAY_OF_MONTH, 30);
cal.set(Calendar.MONTH, 8);
cal.set(Calendar.YEAR, 2020);

Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM);
intent.putExtra(AlarmClock.EXTRA_HOUR, Integer.parseInt(str1));
intent.putExtra(AlarmClock.EXTRA_MINUTES, Integer.parseInt(str2));
intent.putExtra(AlarmClock.EXTRA_MESSAGE, title.getText().toString());
intent.putExtra(AlarmClock.EXTRA_DAYS, cal.get(Calendar.DAY_OF_MONTH));
intent.putExtra(AlarmClock.EXTRA_SKIP_UI, true);
startActivity(intent);
所有这些都很好地设置了我设备上关于时间的应用程序闹钟,但没有设置日期

例如:

  • 当前时间:星期一12:00

    我的代码时间:星期六13:00

    闹钟设置为1小时后播放(铃声)

  • 当前时间:星期一12:00

    我的代码时间:星期二11:00

    闹钟设定在25小时后播放(铃声)

  • 我不知道如何使用这一行代码:

    intent.putExtra(AlarmClock.EXTRA_DAYS,cal.get(Calendar.DAY_OF u MONTH))


    提前感谢

    您无法使用
    AlarmClock
    提供程序为特定日期设置闹钟

    AlarmClock。额外天数用于重复报警。你可以使用日历。星期天之类的东西,它会在每个星期天响


    如果你想对警报有更多的控制,你必须自己编程。查看
    AlarmManager
    类。它允许您安排应用程序在将来的某个时间运行。

    否。您应该传递一周中几天的
    日历
    常量的数组列表,以设置报警。您无法设置具体日期。这是否回答了您的问题@尼古拉斯:不,很不幸