Android时钟应用设置闹钟

Android Clock App Set Alarm

我需要知道这是否可行,如果可行,我应该如何进行。

我想制作一个可以在股票 Android 时钟应用程序中创建重复闹钟的应用程序。它应该在每天早上 8 点关闭,并且只需要一个按钮即可在我的应用程序中激活。

提前致谢

试试这个:

public void createAlarm(String message, int hour, int minutes) {
    Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM)
            .putExtra(AlarmClock.EXTRA_MESSAGE, message)
            .putExtra(AlarmClock.EXTRA_HOUR, hour)
            .putExtra(AlarmClock.EXTRA_MINUTES, minutes);
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}

来源:https://developer.android.com/guide/components/intents-common.html

I found this way for Clock

public void createAlarm(String message, int hour, int minutes) {
    Intent intent = new Intent(AlarmClock.ACTION_SET_ALARM)
            .putExtra(AlarmClock.EXTRA_MESSAGE, message)// show on it
            .putExtra(AlarmClock.EXTRA_HOUR, hour) //24 hours
            .putExtra(AlarmClock.EXTRA_MINUTES, minutes); //not more than 60 :)
    if (intent.resolveActivity(getPackageManager()) != null) {
        startActivity(intent);
    }
}