How to launch Alarm Clock screen using Intent in Android?

前端 未结 3 1059
無奈伤痛
無奈伤痛 2021-01-03 13:03

In my application, i want to add alarm using my App. So i want to launch the add alarm screen of the phone directly from my App. So how to launch it using Intent?

3条回答
  •  执笔经年
    2021-01-03 13:45

    The following code starts an AlarmClock activity:

    Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); 
    i.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm"); 
    i.putExtra(AlarmClock.EXTRA_HOUR, 10); 
    i.putExtra(AlarmClock.EXTRA_MINUTES, 30); 
    startActivity(i); 
    

    You also need to use the following permission:

    com.android.alarm.permission.SET_ALARM

    See Android documentation here.

提交回复
热议问题