意图在Android上启动闹钟设置(在时钟应用程序中)

时间:2013-04-27 21:03:38

标签: android

我在这里找到了如何启动时钟应用程序Intent to launch the clock application on android

但如何在时钟应用程序中直接启动“警报”活动?我知道这是可能的,在市场上看到这样的应用,但找不到合适的解决方案。

1 个答案:

答案 0 :(得分:12)

尝试以下代码:

Intent i = new Intent(AlarmClock.ACTION_SET_ALARM); 
startActivity(i); 

您还可以通过以下操作设置闹钟:

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

您还需要在清单中拥有以下权限:

<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>

有关详细信息,请查看内容here

希望这有帮助!!!

相关问题