• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2018 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License
15  */
16 
17 package android.server.wm.lifecycle;
18 
19 import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK;
20 import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
21 import static android.content.Intent.FLAG_ACTIVITY_MULTIPLE_TASK;
22 import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
23 import static android.content.Intent.FLAG_ACTIVITY_PREVIOUS_IS_TOP;
24 import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
25 import static android.server.wm.ActivityManagerState.STATE_DESTROYED;
26 import static android.server.wm.ActivityManagerState.STATE_RESUMED;
27 import static android.server.wm.ComponentNameUtils.getActivityName;
28 import static android.server.wm.app.Components.ALIAS_TEST_ACTIVITY;
29 import static android.server.wm.app.Components.TEST_ACTIVITY;
30 import static android.server.wm.lifecycle.LifecycleLog.ActivityCallback.ON_RESUME;
31 
32 import static org.junit.Assert.assertEquals;
33 import static org.junit.Assert.assertNotEquals;
34 
35 import android.app.Activity;
36 import android.content.ComponentName;
37 import android.content.Intent;
38 import android.os.Bundle;
39 import android.platform.test.annotations.Presubmit;
40 import android.server.wm.ActivityLauncher;
41 
42 import org.junit.Test;
43 
44 /**
45  * Build/Install/Run:
46  *     atest CtsWindowManagerDeviceTestCases:ActivityStarterTests
47  */
48 @Presubmit
49 public class ActivityStarterTests extends ActivityLifecycleClientTestBase {
50 
51     private static final ComponentName STANDARD_ACTIVITY
52             = getComponentName(StandardActivity.class);
53     private static final ComponentName SECOND_STANDARD_ACTIVITY
54             = getComponentName(SecondStandardActivity.class);
55     private static final ComponentName SINGLE_TOP_ACTIVITY
56             = getComponentName(SingleTopActivity.class);
57     private static final ComponentName SINGLE_INSTANCE_ACTIVITY
58             = getComponentName(SingleInstanceActivity.class);
59     private static final ComponentName SINGLE_TASK_ACTIVITY
60             = getComponentName(SingleTaskActivity.class);
61     private static final ComponentName STANDARD_SINGLE_TOP_ACTIVITY
62             = getComponentName(StandardWithSingleTopActivity.class);
63     private static final ComponentName TEST_LAUNCHING_ACTIVITY
64             = getComponentName(TestLaunchingActivity.class);
65     private static final ComponentName LAUNCHING_AND_FINISH_ACTIVITY
66             = getComponentName(LaunchingAndFinishActivity.class);
67 
68 
69     /**
70      * Ensures that the following launch flag combination works when starting an activity which is
71      * already running:
72      * - {@code FLAG_ACTIVITY_CLEAR_TOP}
73      * - {@code FLAG_ACTIVITY_RESET_TASK_IF_NEEDED}
74      * - {@code FLAG_ACTIVITY_NEW_TASK}
75      */
76     @Test
testClearTopNewTaskResetTask()77     public void testClearTopNewTaskResetTask() throws Exception {
78         // Start activity normally
79         final Activity initialActivity = mFirstActivityTestRule.launchActivity(new Intent());
80         waitAndAssertActivityStates(state(initialActivity, ON_RESUME));
81 
82         // Navigate home
83         launchHomeActivity();
84 
85         // Start activity again with flags in question. Verify activity is resumed.
86         final Intent intent = new Intent().addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP
87                 | Intent.FLAG_ACTIVITY_NEW_TASK
88                 | Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
89         final Activity secondLaunchActivity = mFirstActivityTestRule.launchActivity(intent);
90         mAmWmState.waitForActivityState(secondLaunchActivity.getComponentName(), STATE_RESUMED);
91         assertEquals("The activity should be started and be resumed",
92                 getActivityName(secondLaunchActivity.getComponentName()),
93                 mAmWmState.getAmState().getTopActivityName(0));
94     }
95 
96     /**
97      * This test case tests "standard" activity behavior.
98      * A first launched standard activity and a second launched standard activity
99      * must be in same task.
100      */
101     @Test
testLaunchStandardActivity()102     public void testLaunchStandardActivity() {
103         // Launch a standard activity.
104         launchActivity(STANDARD_ACTIVITY);
105 
106         final int taskId = mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
107         final int instances = mAmWmState.getAmState().getActivityCountInTask(taskId, null);
108 
109         // Launch a second standard activity.
110         launchActivity(SECOND_STANDARD_ACTIVITY);
111 
112         // Make sure instances in task are increased.
113         assertEquals("instances of activity in task must be increased.", instances + 1,
114                 mAmWmState.getAmState().getActivityCountInTask(taskId, null));
115 
116         // Make sure the stack for the second standard activity is front.
117         assertEquals("The stack for the second standard activity must be front.",
118                 getActivityName(SECOND_STANDARD_ACTIVITY),
119                 mAmWmState.getAmState().getTopActivityName(0));
120 
121         // Make sure the standard activity and the second standard activity are in same task.
122         assertEquals("Activity must be in same task.", taskId,
123                 mAmWmState.getAmState().getTaskByActivity(SECOND_STANDARD_ACTIVITY).getTaskId());
124     }
125 
126     /**
127      * This test case tests "single top" activity behavior.
128      * - A first launched standard activity and a second launched single top
129      * activity are in same task.
130      * - A new instance of single top activity is not created if task
131      * already has a its activity at the top of its task.
132      */
133     @Test
testLaunchSingleTopActivity()134     public void testLaunchSingleTopActivity() {
135         // Launch a standard activity.
136         launchActivity(STANDARD_ACTIVITY);
137 
138         final int taskId = mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
139 
140         // Launch a single top activity.
141         launchActivity(SINGLE_TOP_ACTIVITY);
142 
143         final int instances = mAmWmState.getAmState().getActivityCountInTask(taskId, null);
144 
145         // Make sure the single top activity is in focus.
146         mAmWmState.assertFocusedActivity(SINGLE_TOP_ACTIVITY + "must be focused Activity",
147                 SINGLE_TOP_ACTIVITY);
148 
149         // Make sure the stack for the single top activity is front.
150         assertEquals("The stack for the single top activity must be front.",
151                 getActivityName(SINGLE_TOP_ACTIVITY),
152                 mAmWmState.getAmState().getTopActivityName(0));
153 
154         // Make sure the standard activity and the single top activity are in same task.
155         assertEquals("Two activities must be in same task.", taskId,
156                 mAmWmState.getAmState().getTaskByActivity(SINGLE_TOP_ACTIVITY).getTaskId());
157 
158         // Launch a single top activity.
159         launchActivity(SINGLE_TOP_ACTIVITY);
160 
161         // Make sure that instances of activity are not increased.
162         assertEquals("instances of activity must not be increased.", instances,
163                 mAmWmState.getAmState().getActivityCountInTask(taskId, null));
164     }
165 
166     /**
167      * This test case tests "single instance" activity behavior.
168      * - A first launched standard activity and a second launched single instance
169      * activity are not in same task.
170      * - A single instance activity is always the single and only member of its task.
171      */
172     @Test
testLaunchSingleInstanceActivity()173     public void testLaunchSingleInstanceActivity() {
174         // Launch a standard activity.
175         launchActivity(STANDARD_ACTIVITY);
176 
177         final int firstTaskId = mAmWmState.getAmState()
178                 .getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
179 
180         // Launch a single instance activity
181         launchActivity(SINGLE_INSTANCE_ACTIVITY);
182 
183         final int secondTaskId = mAmWmState.getAmState()
184                 .getTaskByActivity(SINGLE_INSTANCE_ACTIVITY).getTaskId();
185 
186         // Make sure the single instance activity is in focus.
187         mAmWmState.assertFocusedActivity(SINGLE_INSTANCE_ACTIVITY + "must be focused Activity",
188                 SINGLE_INSTANCE_ACTIVITY);
189         // Make sure the single instance activity is front.
190         assertEquals("The stack for the single instance activity must be front.",
191                 getActivityName(SINGLE_INSTANCE_ACTIVITY),
192                 mAmWmState.getAmState().getTopActivityName(0));
193 
194         // Make sure the standard activity and the test activity are not in same task.
195         assertNotEquals("Activity must be in different task.", firstTaskId, secondTaskId);
196 
197         // Make sure the single instance activity is only member of its task.
198         assertEquals("Single instance activity is only member of its task", 1,
199                 mAmWmState.getAmState().getActivityCountInTask(secondTaskId, null));
200     }
201 
202     /**
203      * This test case tests "single task" activity behavior.
204      * - A first launched standard activity and a second launched single task activity
205      * are in same task.
206      * - Instance of single task activity is only one in its task.
207      */
208     @Test
testLaunchSingleTaskActivity()209     public void testLaunchSingleTaskActivity() {
210         // Launch a standard activity.
211         launchActivity(STANDARD_ACTIVITY);
212 
213         final int taskId = mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
214 
215         // Launch a single task activity
216         launchActivity(SINGLE_TASK_ACTIVITY);
217 
218         // Make sure the single task activity is in focus.
219         mAmWmState.assertFocusedActivity(SINGLE_TASK_ACTIVITY + "must be focused Activity",
220                 SINGLE_TASK_ACTIVITY);
221 
222         // Make sure the stack for the single task activity is front.
223         assertEquals("The stack for the single task activity must be front.",
224                 getActivityName(SINGLE_TASK_ACTIVITY),
225                 mAmWmState.getAmState().getTopActivityName(0));
226 
227         // Make sure the test activity is in same task.
228         assertEquals("Activity must be in same task.", taskId,
229                 mAmWmState.getAmState().getTaskByActivity(SINGLE_TASK_ACTIVITY).getTaskId());
230 
231         // Launch a second standard activity
232         launchActivity(SECOND_STANDARD_ACTIVITY);
233 
234         // Launch a single task activity again.
235         launchActivity(SINGLE_TASK_ACTIVITY);
236         mAmWmState.waitForActivityState(SECOND_STANDARD_ACTIVITY, STATE_DESTROYED);
237 
238         // Make sure the number of instances for single task activity is only one.
239         assertEquals("Instance of single task activity in its task must be only one", 1,
240                 mAmWmState.getAmState().getActivityCountInTask(taskId, SINGLE_TASK_ACTIVITY));
241         // Make sure that instance of standard activity does not exists.
242         assertEquals("Instance of second standard activity must not exist.", 0,
243                 mAmWmState.getAmState().getActivityCountInTask(taskId, SECOND_STANDARD_ACTIVITY));
244 
245     }
246 
247     /**
248      * Tests that the existing task would be brought to top while launching alias activity or
249      * real activity without creating new activity instances, tasks, or stacks.
250      */
251     @Test
testLaunchAliasActivity()252     public void testLaunchAliasActivity() {
253         // Launch alias activity.
254         getLaunchActivityBuilder().setUseInstrumentation().setTargetActivity(ALIAS_TEST_ACTIVITY)
255                 .setIntentFlags(FLAG_ACTIVITY_NEW_TASK).execute();
256         final int stacks = mAmWmState.getAmState().getStackCounts();
257         final int taskId =
258                 mAmWmState.getAmState().getTaskByActivity(ALIAS_TEST_ACTIVITY).getTaskId();
259 
260         // Return to home and launch the alias activity again.
261         launchHomeActivity();
262         getLaunchActivityBuilder().setUseInstrumentation().setTargetActivity(ALIAS_TEST_ACTIVITY)
263                 .setIntentFlags(FLAG_ACTIVITY_NEW_TASK).execute();
264         assertEquals("Instance of the activity in its task must be only one", 1,
265                 mAmWmState.getAmState().getActivityCountInTask(taskId, ALIAS_TEST_ACTIVITY));
266         assertEquals("Stacks counts should not be increased.", stacks,
267                 mAmWmState.getAmState().getStackCounts());
268 
269         // Return to home and launch the real activity.
270         launchHomeActivity();
271         getLaunchActivityBuilder().setUseInstrumentation().setTargetActivity(TEST_ACTIVITY)
272                 .setIntentFlags(FLAG_ACTIVITY_NEW_TASK).execute();
273         assertEquals("Instance of the activity in its task must be only one", 1,
274                 mAmWmState.getAmState().getActivityCountInTask(taskId, ALIAS_TEST_ACTIVITY));
275         assertEquals("Stacks counts should not be increased.", stacks,
276                 mAmWmState.getAmState().getStackCounts());
277     }
278 
279     /**
280      * This test case tests behavior of activities launched with FLAG_ACTIVITY_NEW_TASK
281      * and FLAG_ACTIVITY_CLEAR_TASK.
282      * A first launched activity is finished, then a second activity is created if the
283      * second activity is launched with FLAG_ACTIVITY_NEW_TASK and FLAG_ACTIVITY_CLEAR_TASK.
284      */
285     @Test
testLaunchActivityWithFlagNewTaskAndClearTask()286     public void testLaunchActivityWithFlagNewTaskAndClearTask() {
287         // Launch a standard activity with FLAG_ACTIVITY_NEW_TASK.
288         getLaunchActivityBuilder()
289                 .setTargetActivity(STANDARD_ACTIVITY)
290                 .setIntentFlags(FLAG_ACTIVITY_NEW_TASK)
291                 .execute();
292 
293         final int taskId = mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
294 
295         // Launch Activity with FLAG_ACTIVITY_NEW_TASK|FLAG_ACTIVITY_CLEAR_TASK.
296         getLaunchActivityBuilder()
297                 .setTargetActivity(STANDARD_ACTIVITY)
298                 .setLaunchingActivity(TEST_LAUNCHING_ACTIVITY)
299                 .setIntentFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)
300                 .execute();
301 
302         mAmWmState.waitForActivityState(STANDARD_ACTIVITY, STATE_DESTROYED);
303 
304         // Make sure the number of instances for standard activity is one
305         // because previous standard activity to be finished due to FLAG_ACTIVITY_CLEAR_TASK.
306         assertEquals("Instance of activity must be one", 1,
307                 mAmWmState.getAmState().getActivityCountInTask(taskId, STANDARD_ACTIVITY));
308 
309         // Make sure the stack for the standard activity is front.
310         assertEquals("The stack for the standard activity must be front.",
311                 getActivityName(STANDARD_ACTIVITY),
312                 mAmWmState.getAmState().getTopActivityName(0));
313     }
314 
315     /**
316      * This test case tests behavior of activity launched with FLAG_ACTIVITY_CLEAR_TOP.
317      * A top activity is finished when an activity is launched with FLAG_ACTIVITY_CLEAR_TOP.
318      */
319     @Test
testLaunchActivityWithFlagClearTop()320     public void testLaunchActivityWithFlagClearTop() {
321         // Launch a standard activity
322         getLaunchActivityBuilder()
323                 .setTargetActivity(STANDARD_ACTIVITY)
324                 .execute();
325 
326         final int taskId = mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
327 
328         // Launch a second standard activity
329         getLaunchActivityBuilder()
330                 .setTargetActivity(SECOND_STANDARD_ACTIVITY)
331                 .setLaunchingActivity(TEST_LAUNCHING_ACTIVITY)
332                 .execute();
333 
334         // Launch a standard activity again with CLEAR_TOP_FLAG
335         getLaunchActivityBuilder()
336                 .setTargetActivity(STANDARD_ACTIVITY)
337                 .setLaunchingActivity(TEST_LAUNCHING_ACTIVITY)
338                 .setIntentFlags(FLAG_ACTIVITY_CLEAR_TOP)
339                 .execute();
340 
341         mAmWmState.waitForActivityState(STANDARD_ACTIVITY, STATE_RESUMED);
342 
343         // Make sure that the standard activity is in focus.
344         mAmWmState.assertFocusedActivity(STANDARD_ACTIVITY + "must be focused Activity",
345                 STANDARD_ACTIVITY);
346 
347         // Make sure the stack for the standard activity is front.
348         assertEquals("The stack for the standard activity must be front.",
349                 getActivityName(STANDARD_ACTIVITY),
350                 mAmWmState.getAmState().getTopActivityName(0));
351 
352         // Make sure the activity is not in same task.
353         assertEquals("Activity must be in same task.", taskId,
354                 mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId());
355         // Make sure the second standard activity is finished.
356         final String waitFinishMsg = "Instance of second standard activity must not exist";
357         mAmWmState.waitForWithAmState((amState) ->
358             0 == amState.getActivityCountInTask(taskId, SECOND_STANDARD_ACTIVITY),
359             waitFinishMsg);
360         assertEquals(waitFinishMsg, 0,
361             mAmWmState.getAmState().getActivityCountInTask(taskId, SECOND_STANDARD_ACTIVITY));
362     }
363 
364     @Test
testLaunchActivityWithFlagPreviousIsTop()365     public void testLaunchActivityWithFlagPreviousIsTop() {
366         // Launch a standard activity
367         getLaunchActivityBuilder()
368                 .setTargetActivity(SINGLE_TOP_ACTIVITY)
369                 .execute();
370 
371         final int taskId = mAmWmState.getAmState().getTaskByActivity(
372                 SINGLE_TOP_ACTIVITY).getTaskId();
373 
374         // Launch a standard activity again with PREVIOUS_IS_TOP
375         getLaunchActivityBuilder()
376                 .setTargetActivity(SINGLE_TOP_ACTIVITY)
377                 .setLaunchingActivity(LAUNCHING_AND_FINISH_ACTIVITY)
378                 .setIntentFlags(FLAG_ACTIVITY_PREVIOUS_IS_TOP)
379                 .execute();
380 
381         assertEquals("Instance of activity must be one", 1,
382                 mAmWmState.getAmState().getActivityCountInTask(taskId, SINGLE_TOP_ACTIVITY));
383     }
384 
385     /**
386      * This test case tests behavior of activity launched with FLAG_ACTIVITY_SINGLE_TOP.
387      * A single top activity must not be launched if it is already running at the top
388      * of the history stack.
389      */
390     @Test
testLaunchActivityWithFlagSingleTop()391     public void testLaunchActivityWithFlagSingleTop() {
392         // Launch a standard activity
393         getLaunchActivityBuilder()
394                 .setTargetActivity(STANDARD_ACTIVITY)
395                 .execute();
396 
397         final int taskId = mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
398 
399         // Launch a standard activity with SINGLE_TOP flag.
400         // This standard activity launches a standard activity with single top flag.
401         getLaunchActivityBuilder()
402                 .setTargetActivity(STANDARD_SINGLE_TOP_ACTIVITY)
403                 .setLaunchingActivity(TEST_LAUNCHING_ACTIVITY)
404                 .setIntentFlags(FLAG_ACTIVITY_SINGLE_TOP)
405                 .execute();
406 
407         mAmWmState.waitForActivityState(STANDARD_SINGLE_TOP_ACTIVITY, STATE_RESUMED);
408 
409         // Make sure that a new instance is not created if it is already running at the top
410         // of the history stack.
411         assertEquals("Multiple single top activities must not be created.", 1,
412                 mAmWmState.getAmState()
413                         .getActivityCountInTask(taskId, STANDARD_SINGLE_TOP_ACTIVITY));
414 
415 
416         // Make sure that activity is in focus.
417         mAmWmState.assertFocusedActivity(STANDARD_SINGLE_TOP_ACTIVITY + "must be focused Activity",
418                 STANDARD_SINGLE_TOP_ACTIVITY);
419         // Make sure the stack for the single top activity is front.
420         assertEquals("The stack for the single top activity must be front.",
421                 getActivityName(STANDARD_SINGLE_TOP_ACTIVITY),
422                 mAmWmState.getAmState().getTopActivityName(0));
423 
424         // Make sure the standard activity and the single top activity are in same task.
425         assertEquals("Activity must be in same task.", taskId,
426                 mAmWmState.getAmState().getTaskByActivity(STANDARD_SINGLE_TOP_ACTIVITY)
427                         .getTaskId());
428     }
429 
430     /**
431      * This test case tests behavior of activity launched with FLAG_ACTIVITY_MULTIPLE_TASK
432      * and FLAG_ACTIVITY_NEW_TASK.
433      * Second launched activity which is launched with FLAG_ACTIVITY_MULTIPLE_TASK and
434      * FLAG_ACTIVITY_NEW_TASK is created in new task/stack. So, a first launched activity
435      * and a second launched activity are in different task/stack.
436      */
437     @Test
testActivityWithFlagMultipleTaskAndNewTask()438     public void testActivityWithFlagMultipleTaskAndNewTask() {
439         // Launch a standard activity
440         getLaunchActivityBuilder()
441                 .setTargetActivity(STANDARD_ACTIVITY)
442                 .setIntentFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK)
443                 .execute();
444 
445         final int taskId = mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId();
446 
447         // Launch a standard activity with FLAG_ACTIVITY_MULTIPLE_TASK|FLAG_ACTIVITY_NEW_TASK
448         getLaunchActivityBuilder()
449                 .setTargetActivity(STANDARD_ACTIVITY)
450                 .setLaunchingActivity(TEST_LAUNCHING_ACTIVITY)
451                 .setIntentFlags(FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_MULTIPLE_TASK)
452                 .execute();
453 
454         // Make sure the stack for the standard activity is front.
455         assertEquals("The stack for the standard activity must be front.",
456                 getActivityName(STANDARD_ACTIVITY),
457                 mAmWmState.getAmState().getTopActivityName(0));
458         // Make sure the first standard activity and second standard activity are not in same task.
459         assertNotEquals("Activity must not be in same task.", taskId,
460                 mAmWmState.getAmState().getTaskByActivity(STANDARD_ACTIVITY).getTaskId());
461     }
462 
463     // Test activity
464     public static class StandardActivity extends Activity {
465     }
466 
467     // Test activity
468     public static class SecondStandardActivity extends Activity {
469     }
470 
471     // Test activity
472     public static class StandardWithSingleTopActivity extends Activity {
473 
474         @Override
onCreate(Bundle savedInstanceState)475         protected void onCreate(Bundle savedInstanceState) {
476             super.onCreate(savedInstanceState);
477             final Intent intent = new Intent().setComponent(
478                     new ComponentName(this /* context */, getClass()));
479             intent.addFlags(FLAG_ACTIVITY_SINGLE_TOP);
480             startActivity(intent);
481         }
482     }
483 
484     // Test activity
485     public static class SingleTopActivity extends Activity {
486     }
487 
488     // Test activity
489     public static class SingleTaskActivity extends Activity {
490     }
491 
492     // Test activity
493     public static class SingleInstanceActivity extends Activity {
494     }
495 
496     // Launching activity
497     public static class TestLaunchingActivity extends Activity {
498         @Override
onCreate(Bundle savedInstanceState)499         protected void onCreate(Bundle savedInstanceState) {
500             super.onCreate(savedInstanceState);
501 
502             final Intent intent = getIntent();
503             if (intent != null) {
504                 ActivityLauncher.launchActivityFromExtras(this, intent.getExtras());
505             }
506         }
507 
508         @Override
onNewIntent(Intent intent)509         protected void onNewIntent(Intent intent) {
510             super.onNewIntent(intent);
511             ActivityLauncher.launchActivityFromExtras(this, intent.getExtras());
512         }
513     }
514 
515     public static class LaunchingAndFinishActivity extends TestLaunchingActivity {
516         @Override
onCreate(Bundle savedInstanceState)517         protected void onCreate(Bundle savedInstanceState) {
518             super.onCreate(savedInstanceState);
519             finish();
520         }
521     }
522 }
523