title: How does one launch android version dependent alarm clock?
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/3590955/intent-to-launch-the-clock-application-on-android">Intent to launch the clock application on android</a>  </p>
  </blockquote>
  
  
  
  <p>I have a widget that displays the time and if one taps on it, it launches the com.android.alarmclock/.AlarmClock activity with an <code>PendingIntent</code>.  This works great before-Froyo, but with Froyo, I have to launch the com.android.deskclock/.AlarmClock.  So I want to put in code that checks for the class existence and launch the appropriate activity/intent.  Here is what I tried, but it does not work.</p>
  
  <pre><code>Intent alarmIntent = new Intent();
  try {
      if (Class.forName("com.android.deskclock.AlarmClock") != null) {
      Log.i(TAG, "setting deskclock alarm -- must be Froyo!");
      alarmIntent.setClassName("com.android.deskclock",
          "com.android.deskclock.AlarmClock");
      }
  } catch (ClassNotFoundException e) {
      Log.i(TAG, "setting alarmclock alarm -- must be Eclair!");
      alarmIntent.setClassName("com.android.alarmclock",
          "com.android.alarmclock.AlarmClock");
  }
  PendingIntent pendingIntent = PendingIntent.getActivity(context, REQUEST_UPDATE_TIME_NOW,
      alarmIntent, PendingIntent.FLAG_UPDATE_CURRENT);
  views.setOnClickPendingIntent(R.id.text_timeofday, pendingIntent);
  </code></pre>
  
  <p>It always thinks it is "Eclair" and therefore fails on Froyo.  Is this the best approach, or should I check the application-level?  I prefer to work with the class existence.</p>