Android的AlarmClock的ACTION_SET_ALARM意图产生异常意图、异常、Android、AlarmClock

2023-09-06 15:19:27 作者:可爱侵袭症

给出的例子产生一个异常(android.content.ActivityNotFoundException:无活动办理意向)

 意向书我=新的意图(AlarmClock.ACTION_SET_ALARM);
i.putExtra(AlarmClock.EXTRA_MESSAGE,新报警);
i.putExtra(AlarmClock.EXTRA_HOUR,小时);
i.putExtra(AlarmClock.EXTRA_MINUTES,分钟);
startActivity(ⅰ);
 

在我SGS2 Android版本2.3.3。你有什么想法,有什么可以去错了吗?一个又一个的意图请求(例如选择从地址簿中的联系人)正常工作。

感谢您, Artjom

解决方案   

你有什么想法,有什么可以去错了吗?

本设备不支持该活动。这不是闻所未闻的。无论是捕获异常,并让用户知道,或者使用 PackageManager queryIntentActivities()来看看是否有什么将响应你的意图提前调用的 startActivity()

Alarm CLOCK

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

解决方案

Do you have any ideas, what can be going wrong?

The device does not support that activity. This is not unheard of. Either catch the exception and let the user know, or use PackageManager and queryIntentActivities() to see if anything will respond to your Intent in advance of calling startActivity().