Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android AlarmClock ACTION_SET_ALARM intent produces exception

Tags:

android

alarm

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

like image 881
artkoenig Avatar asked Sep 05 '11 08:09

artkoenig


2 Answers

You need to set permission in manifest file also.

<uses-permission android:name="com.android.alarm.permission.SET_ALARM"/>
like image 163
Manshi Avatar answered Oct 05 '22 08:10

Manshi


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().

like image 28
CommonsWare Avatar answered Oct 05 '22 07:10

CommonsWare