diff --git a/api/test-current.txt b/api/test-current.txt index 703e71be90508..39020b43109cc 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -117,6 +117,7 @@ package android.app { method public void startActivity(@NonNull android.content.Intent); method public void startActivity(@NonNull android.content.Intent, android.os.UserHandle); method public void startActivity(@NonNull android.app.PendingIntent); + method public void startActivity(@NonNull android.app.PendingIntent, @NonNull android.app.ActivityOptions); } public abstract static class ActivityView.StateCallback { diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java index 0ccaf62d45b28..fc6fffabc9171 100644 --- a/core/java/android/app/ActivityView.java +++ b/core/java/android/app/ActivityView.java @@ -254,6 +254,34 @@ public class ActivityView extends ViewGroup { } } + /** + * Launch a new activity into this container. + *

Activity resolved by the provided {@link PendingIntent} must have + * {@link android.R.attr#resizeableActivity} attribute set to {@code true} in order to be + * launched here. Also, if activity is not owned by the owner of this container, it must allow + * embedding and the caller must have permission to embed. + *

Note: This class must finish initializing and + * {@link StateCallback#onActivityViewReady(ActivityView)} callback must be triggered before + * this method can be called. + * + * @param pendingIntent Intent used to launch an activity. + * @param options options for the activity + * + * @see StateCallback + * @see #startActivity(Intent) + */ + public void startActivity(@NonNull PendingIntent pendingIntent, + @NonNull ActivityOptions options) { + options.setLaunchDisplayId(mVirtualDisplay.getDisplay().getDisplayId()); + try { + pendingIntent.send(null /* context */, 0 /* code */, null /* intent */, + null /* onFinished */, null /* handler */, null /* requiredPermission */, + options.toBundle()); + } catch (PendingIntent.CanceledException e) { + throw new RuntimeException(e); + } + } + /** * Check if container is ready to launch and create {@link ActivityOptions} to target the * virtual display. diff --git a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java index 63db3618f3e21..346660df7fb5c 100644 --- a/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java +++ b/packages/SystemUI/src/com/android/systemui/bubbles/BubbleExpandedView.java @@ -25,6 +25,7 @@ import static android.view.Display.INVALID_DISPLAY; import android.animation.LayoutTransition; import android.animation.ObjectAnimator; import android.annotation.Nullable; +import android.app.ActivityOptions; import android.app.ActivityView; import android.app.INotificationManager; import android.app.Notification; @@ -121,7 +122,11 @@ public class BubbleExpandedView extends LinearLayout implements View.OnClickList public void onActivityViewReady(ActivityView view) { if (!mActivityViewReady) { mActivityViewReady = true; - mActivityView.startActivity(mBubbleIntent); + // Custom options so there is no activity transition animation + ActivityOptions options = ActivityOptions.makeCustomAnimation(getContext(), + 0 /* enterResId */, 0 /* exitResId */); + // Post to keep the lifecycle normal + post(() -> mActivityView.startActivity(mBubbleIntent, options)); } }