Skip to content Skip to sidebar Skip to footer

How Does One Launch Android Version Dependent Alarm Clock?

Possible Duplicate: Intent to launch the clock application on android I have a widget that displays the time and if one taps on it, it launches the com.android.alarmclock/.Alarm

Solution 1:

if (Class.forName("com.android.deskclock.AlarmClock") != null)

That won't work, because that class is not in your project. At most, it might be in some other project on the device.

There is no documented supported Intent for launching an alarm clock in the Android SDK. Your approach of hard-wiring in package and class names is fragile, as you're discovering. It won't work on some devices, if they do not have that application (e.g., replaced by one from the device manufacturer). Plus, as you've seen, it may change in future versions of Android. I am having a rough enough time trying to convince device manufacturers not to break the SDK; having third-party developers do it weakens my case.

That being said, the general way to see if something will respond to an Intent is to use PackageManager (e.g., queryIntentActivities()).

Post a Comment for "How Does One Launch Android Version Dependent Alarm Clock?"