OSDN Git Service

Start new task for Gallery trampolines
authorAlan Newberger <alann@google.com>
Sat, 9 Aug 2014 02:03:55 +0000 (19:03 -0700)
committerAlan Newberger <alann@google.com>
Sat, 9 Aug 2014 02:07:39 +0000 (19:07 -0700)
When testing the Camera trampoline, even in the full gallery app
from a JB to K upgrade, I noticed that the Camera app was starting
in the Gallery trampoline's task -- two recents even with
excludeFromRecents true. Was still the case in the new trampoline.
Adding FLAG_ACTIVITY_NEW_TASK addressed this, also with some
manifest changes in the trampoline in another CL. Photos was working,
I believe because photos activities explicitly set a task affinity
to shield themselves from G+, thus forcing a new task. Also, this
helped shield activities when both trampolines are active. That is,
if Camera was started via its trampoline, then Photos, the Photos
shortcut opened Camera because it already had an activity in the
trampoline's task. Even if Photos works now, this does no harm and
ensures we're not relying on the implementation of another APK.

Bug: 16843573
Change-Id: Ifa6d65ef2b00a4ffc6df78f13dba16270113509d

src/com/android/camera/CameraActivity.java
src/com/android/gallery3d/app/Gallery.java

index 4ed6309..b74af47 100644 (file)
@@ -31,6 +31,7 @@ public class CameraActivity extends Activity {
         // it's already in a new task. Start Camera activity and
         // reset the task to its initial state if needed.
         intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(intent);
         finish();
     }
index a1b6d01..fd9097d 100644 (file)
@@ -31,6 +31,7 @@ public class Gallery extends Activity {
         // it's already in a new task. Start Gallery activity and
         // reset the task to its initial state if needed.
         intent.setFlags(Intent.FLAG_ACTIVITY_RESET_TASK_IF_NEEDED);
+        intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
         startActivity(intent);
         finish();
     }