Android AlarmClock ACTION_SET_ALARM 意图产生异常
产生异常(android.content.ActivityNotFoundException:找不到处理 Intent 的活动)
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm");
i.putExtra(AlarmClock.EXTRA_HOUR, hours);
i.putExtra(AlarmClock.EXTRA_MINUTES, mins);
startActivity(i);
给定的示例在我的 SGS2 Android 版本 2.3.3 上 。您有什么想法吗?可能出了什么问题?另一个意图请求(例如从地址簿中选择联系人)工作正常。
谢谢你, 阿尔乔姆
The given example produces an Exception (android.content.ActivityNotFoundException: No Activity found to handle Intent)
Intent i = new Intent(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_MESSAGE, "New Alarm");
i.putExtra(AlarmClock.EXTRA_HOUR, hours);
i.putExtra(AlarmClock.EXTRA_MINUTES, mins);
startActivity(i);
on my SGS2 Android Version 2.3.3. Do you have any ideas, what can be going wrong? An another intent request (e.g. selecting a contact from the address book) works fine.
Thank you,
Artjom
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您还需要在清单文件中设置权限。
You need to set permission in manifest file also.
该设备不支持该活动。这并非闻所未闻。捕获异常并让用户知道,或者使用
PackageManager
和queryIntentActivities()
来查看是否有任何内容会提前响应您的Intent
调用startActivity()。The device does not support that activity. This is not unheard of. Either catch the exception and let the user know, or use
PackageManager
andqueryIntentActivities()
to see if anything will respond to yourIntent
in advance of callingstartActivity()
.