From: Dianne Hackborn Date: Mon, 13 Dec 2010 20:46:19 +0000 (-0800) Subject: Update to use help APIs. X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=11371e6d365788cfa494942e6421289fbb713b57;p=android-x86%2Fdevelopment.git Update to use help APIs. Change-Id: I11bab7b66376b34303e8e84460236a1ff7a475b2 --- diff --git a/samples/ApiDemos/src/com/example/android/apis/app/IntentActivityFlags.java b/samples/ApiDemos/src/com/example/android/apis/app/IntentActivityFlags.java index e93ea431..caf9d0f6 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/IntentActivityFlags.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/IntentActivityFlags.java @@ -5,6 +5,7 @@ import com.example.android.apis.R; import android.app.Activity; import android.app.PendingIntent; import android.app.PendingIntent.CanceledException; +import android.content.ComponentName; import android.content.Context; import android.content.Intent; import android.os.Bundle; @@ -36,24 +37,19 @@ public class IntentActivityFlags extends Activity { */ //BEGIN_INCLUDE(intent_array) private Intent[] buildIntentsToViewsLists() { - // We will use FLAG_ACTIVITY_CLEAR_TASK to complete replace our - // current task with a new Intent. + // We are going to rebuild our task with a new back stack. This will + // be done by launching an array of Intents, representing the new + // back stack to be created, with the first entry holding the root + // and requesting to reset the back stack. Intent[] intents = new Intent[3]; - // The main activity started from launcher is action MAIN and - // category LAUNCHER; we want to match that. - Intent intent = new Intent(Intent.ACTION_MAIN); - intent.addCategory(Intent.CATEGORY_LAUNCHER); - // We will use FLAG_ACTIVITY_CLEAR_TASK to completely replace our - // current task with a new Intent. - intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_CLEAR_TASK); - - // Set the actual activity to launch. - intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class); - intents[0] = intent; + // First: root activity of ApiDemos. + // This is a convenient way to make the proper Intent to launch and + // reset an application's task. + intents[0] = Intent.makeRestartActivityTask(new ComponentName(this, + com.example.android.apis.ApiDemos.class)); - intent = new Intent(Intent.ACTION_MAIN); + Intent intent = new Intent(Intent.ACTION_MAIN); intent.setClass(IntentActivityFlags.this, com.example.android.apis.ApiDemos.class); intent.putExtra("com.example.android.apis.Path", "Views"); intents[1] = intent; diff --git a/samples/ApiDemos/src/com/example/android/apis/app/StatusBarNotifications.java b/samples/ApiDemos/src/com/example/android/apis/app/StatusBarNotifications.java index b506012c..7179b25e 100644 --- a/samples/ApiDemos/src/com/example/android/apis/app/StatusBarNotifications.java +++ b/samples/ApiDemos/src/com/example/android/apis/app/StatusBarNotifications.java @@ -22,6 +22,7 @@ import android.app.Activity; import android.app.Notification; import android.app.NotificationManager; import android.app.PendingIntent; +import android.content.ComponentName; import android.content.Intent; import android.os.Bundle; import android.view.View; @@ -164,15 +165,10 @@ public class StatusBarNotifications extends Activity { Intent[] intents = new Intent[4]; // First: root activity of ApiDemos. - // The main activity started from launcher is action MAIN and - // category LAUNCHER; we want to match that. - intents[0] = new Intent(Intent.ACTION_MAIN); - intents[0].addCategory(Intent.CATEGORY_LAUNCHER); - // We will use FLAG_ACTIVITY_CLEAR_TASK to completely replace our - // current task with a new Intent. - intents[0].addFlags(Intent.FLAG_ACTIVITY_NEW_TASK - | Intent.FLAG_ACTIVITY_CLEAR_TASK); - intents[0].setClass(this, com.example.android.apis.ApiDemos.class); + // This is a convenient way to make the proper Intent to launch and + // reset an application's task. + intents[0] = Intent.makeRestartActivityTask(new ComponentName(this, + com.example.android.apis.ApiDemos.class)); // "App" intents[1] = new Intent(this, com.example.android.apis.ApiDemos.class);