OSDN Git Service

Fix http://b/2232909 .
authorDaniel Sandler <dsandler@google.com>
Wed, 11 Nov 2009 19:27:00 +0000 (11:27 -0800)
committerDaniel Sandler <dsandler@google.com>
Wed, 11 Nov 2009 19:27:00 +0000 (11:27 -0800)
Rather than being fancy and firing off the NOW_PLAYING
activity (which doesn't like to be launched if nothing's
playing), we just launch the Music app as if it were
starting from Launcher.

src/com/android/deskclock/DeskClock.java

index 0cb23c8..c7164fb 100644 (file)
@@ -89,9 +89,10 @@ public class DeskClock extends Activity {
 
     private static final String LOG_TAG = "DeskClock";
 
-    // Intent used to start the music player.
-    private static final String MUSIC_NOW_PLAYING = "com.android.music.PLAYBACK_VIEWER";
+    // Package ID of the music player.
+    private static final String MUSIC_PACKAGE_ID = "com.android.music";
 
+    // Alarm action for midnight (so we can update the date display).
     private static final String ACTION_MIDNIGHT = "com.android.deskclock.MIDNIGHT";
 
     // Interval between polls of the weather widget. Its refresh period is
@@ -633,7 +634,10 @@ public class DeskClock extends Activity {
         musicButton.setOnClickListener(new View.OnClickListener() {
             public void onClick(View v) {
                 try {
-                    startActivity(new Intent(MUSIC_NOW_PLAYING));
+                    Intent musicAppQuery = getPackageManager().getLaunchIntentForPackage(MUSIC_PACKAGE_ID);
+                    if (musicAppQuery != null) {
+                        startActivity(musicAppQuery);
+                    }
                 } catch (android.content.ActivityNotFoundException e) {
                     Log.e(LOG_TAG, "Couldn't launch music browser", e);
                 }