Merge "Make lifecycle events for bubble activity views report normally" into qt-dev
This commit is contained in:
@@ -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 {
|
||||
|
||||
@@ -254,6 +254,34 @@ public class ActivityView extends ViewGroup {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Launch a new activity into this container.
|
||||
* <p>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.
|
||||
* <p>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.
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user