Android AlarmClock ACTION_SET_ALARM throws an exception

This example throws 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 version of SGS2 Android 2.3.3. Do you have any ideas what might be wrong? Another request for intent (for example, selecting a contact from the address book) works fine.

Thank you Artjom

+5
source share
2 answers

Do you have any ideas what might be wrong?

The device does not support this activity. This is unheard of. Either catch the exception and report it to the user, or use PackageManagerand queryIntentActivities()to find out something will answer yours Intentbefore the call startActivity().

+5

.

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

All Articles