belongs to Maven artifact com.android.support:support-compat:28.0.0-alpha1
ActivityOptionsCompat
public
class
ActivityOptionsCompat
extends Object
java.lang.Object | |
↳ | android.support.v4.app.ActivityOptionsCompat |
Helper for accessing features in ActivityOptions
in a backwards compatible
fashion.
Summary
Constants | |
---|---|
String |
EXTRA_USAGE_TIME_REPORT
A long in the extras delivered by |
String |
EXTRA_USAGE_TIME_REPORT_PACKAGES
A Bundle in the extras delivered by |
Protected constructors | |
---|---|
ActivityOptionsCompat()
|
Public methods | |
---|---|
Rect
|
getLaunchBounds()
Returns the bounds that should be used to launch the activity. |
static
ActivityOptionsCompat
|
makeBasic()
Create a basic ActivityOptions that has no special animation associated with it. |
static
ActivityOptionsCompat
|
makeClipRevealAnimation(View source, int startX, int startY, int width, int height)
Create an ActivityOptions specifying an animation where the new activity is revealed from a small originating area of the screen to its final full representation. |
static
ActivityOptionsCompat
|
makeCustomAnimation(Context context, int enterResId, int exitResId)
Create an ActivityOptions specifying a custom animation to run when the activity is displayed. |
static
ActivityOptionsCompat
|
makeScaleUpAnimation(View source, int startX, int startY, int startWidth, int startHeight)
Create an ActivityOptions specifying an animation where the new activity is scaled from a small originating area of the screen to its final full representation. |
static
ActivityOptionsCompat
|
makeSceneTransitionAnimation(Activity activity, Pair...<View, String> sharedElements)
Create an ActivityOptions to transition between Activities using cross-Activity scene animations. |
static
ActivityOptionsCompat
|
makeSceneTransitionAnimation(Activity activity, View sharedElement, String sharedElementName)
Create an ActivityOptions to transition between Activities using cross-Activity scene animations. |
static
ActivityOptionsCompat
|
makeTaskLaunchBehind()
If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be presented to the user but will instead be only available through the recents task list. |
static
ActivityOptionsCompat
|
makeThumbnailScaleUpAnimation(View source, Bitmap thumbnail, int startX, int startY)
Create an ActivityOptions specifying an animation where a thumbnail is scaled from a given position to the new activity window that is being started. |
void
|
requestUsageTimeReport(PendingIntent receiver)
Ask the the system track that time the user spends in the app being launched, and report it back once done. |
ActivityOptionsCompat
|
setLaunchBounds(Rect screenSpacePixelRect)
Sets the bounds (window size) that the activity should be launched in. |
Bundle
|
toBundle()
Returns the created options as a Bundle, which can be passed to
|
void
|
update(ActivityOptionsCompat otherOptions)
Update the current values in this ActivityOptions from those supplied in otherOptions. |
Inherited methods | |
---|---|
![]()
java.lang.Object
|
Constants
EXTRA_USAGE_TIME_REPORT
String EXTRA_USAGE_TIME_REPORT
A long in the extras delivered by requestUsageTimeReport(PendingIntent)
that contains
the total time (in ms) the user spent in the app flow.
Constant Value: "android.activity.usage_time"
EXTRA_USAGE_TIME_REPORT_PACKAGES
String EXTRA_USAGE_TIME_REPORT_PACKAGES
A Bundle in the extras delivered by requestUsageTimeReport(PendingIntent)
that contains
detailed information about the time spent in each package associated with the app;
each key is a package name, whose value is a long containing the time (in ms).
Constant Value: "android.usage_time_packages"
Protected constructors
Public methods
getLaunchBounds
Rect getLaunchBounds ()
Returns the bounds that should be used to launch the activity.
Returns | |
---|---|
Rect |
Bounds used to launch the activity. |
See also:
makeBasic
ActivityOptionsCompat makeBasic ()
Create a basic ActivityOptions that has no special animation associated with it. Other options can still be set.
Returns | |
---|---|
ActivityOptionsCompat |
makeClipRevealAnimation
ActivityOptionsCompat makeClipRevealAnimation (View source, int startX, int startY, int width, int height)
Create an ActivityOptions specifying an animation where the new activity is revealed from a small originating area of the screen to its final full representation.
Parameters | |
---|---|
source |
View : The View that the new activity is animating from. This
defines the coordinate space for startX and startY. |
startX |
int : The x starting location of the new activity, relative to source. |
startY |
int : The y starting location of the activity, relative to source. |
width |
int : The initial width of the new activity. |
height |
int : The initial height of the new activity. |
Returns | |
---|---|
ActivityOptionsCompat |
Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |
makeCustomAnimation
ActivityOptionsCompat makeCustomAnimation (Context context, int enterResId, int exitResId)
Create an ActivityOptions specifying a custom animation to run when the activity is displayed.
Parameters | |
---|---|
context |
Context : Who is defining this. This is the application that the
animation resources will be loaded from. |
enterResId |
int : A resource ID of the animation resource to use for the
incoming activity. Use 0 for no animation. |
exitResId |
int : A resource ID of the animation resource to use for the
outgoing activity. Use 0 for no animation. |
Returns | |
---|---|
ActivityOptionsCompat |
Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |
makeScaleUpAnimation
ActivityOptionsCompat makeScaleUpAnimation (View source, int startX, int startY, int startWidth, int startHeight)
Create an ActivityOptions specifying an animation where the new activity is scaled from a small originating area of the screen to its final full representation.
If the Intent this is being used with has not set itssetSourceBounds(android.graphics.Rect)
,
those bounds will be filled in for you based on the initial bounds passed
in here.
Parameters | |
---|---|
source |
View : The View that the new activity is animating from. This
defines the coordinate space for startX and startY. |
startX |
int : The x starting location of the new activity, relative to
source. |
startY |
int : The y starting location of the activity, relative to source. |
startWidth |
int : The initial width of the new activity. |
startHeight |
int : The initial height of the new activity. |
Returns | |
---|---|
ActivityOptionsCompat |
Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |
makeSceneTransitionAnimation
ActivityOptionsCompat makeSceneTransitionAnimation (Activity activity, Pair...<View, String> sharedElements)
Create an ActivityOptions to transition between Activities using cross-Activity scene animations. This method carries the position of multiple shared elements to the started Activity. The position of the first element in sharedElements will be used as the epicenter for the exit Transition. The position of the associated shared element in the launched Activity will be the epicenter of its entering Transition.
This requires FEATURE_CONTENT_TRANSITIONS
to be
enabled on the calling Activity to cause an exit transition. The same must be in
the called Activity to get an entering transition.
Parameters | |
---|---|
activity |
Activity : The Activity whose window contains the shared elements. |
sharedElements |
Pair : The names of the shared elements to transfer to the called
Activity and their associated Views. The Views must each have
a unique shared element name. |
Returns | |
---|---|
ActivityOptionsCompat |
Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |
makeSceneTransitionAnimation
ActivityOptionsCompat makeSceneTransitionAnimation (Activity activity, View sharedElement, String sharedElementName)
Create an ActivityOptions to transition between Activities using cross-Activity scene
animations. This method carries the position of one shared element to the started Activity.
The position of sharedElement
will be used as the epicenter for the
exit Transition. The position of the shared element in the launched Activity will be the
epicenter of its entering Transition.
This requires FEATURE_CONTENT_TRANSITIONS
to be
enabled on the calling Activity to cause an exit transition. The same must be in
the called Activity to get an entering transition.
Parameters | |
---|---|
activity |
Activity : The Activity whose window contains the shared elements. |
sharedElement |
View : The View to transition to the started Activity. sharedElement must
have a non-null sharedElementName. |
sharedElementName |
String : The shared element name as used in the target Activity. This may
be null if it has the same name as sharedElement. |
Returns | |
---|---|
ActivityOptionsCompat |
Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |
makeTaskLaunchBehind
ActivityOptionsCompat makeTaskLaunchBehind ()
If set along with Intent.FLAG_ACTIVITY_NEW_DOCUMENT then the task being launched will not be presented to the user but will instead be only available through the recents task list. In addition, the new task wil be affiliated with the launching activity's task. Affiliated tasks are grouped together in the recents task list.
This behavior is not supported for activities with
launchMode
values of
singleInstance
or singleTask
.
Returns | |
---|---|
ActivityOptionsCompat |
makeThumbnailScaleUpAnimation
ActivityOptionsCompat makeThumbnailScaleUpAnimation (View source, Bitmap thumbnail, int startX, int startY)
Create an ActivityOptions specifying an animation where a thumbnail is scaled from a given position to the new activity window that is being started.
If the Intent this is being used with has not set itssetSourceBounds(android.graphics.Rect)
,
those bounds will be filled in for you based on the initial thumbnail
location and size provided here.
Parameters | |
---|---|
source |
View : The View that this thumbnail is animating from. This
defines the coordinate space for startX and startY. |
thumbnail |
Bitmap : The bitmap that will be shown as the initial thumbnail
of the animation. |
startX |
int : The x starting location of the bitmap, relative to source. |
startY |
int : The y starting location of the bitmap, relative to source. |
Returns | |
---|---|
ActivityOptionsCompat |
Returns a new ActivityOptions object that you can use to supply these options as the options Bundle when starting an activity. |
requestUsageTimeReport
void requestUsageTimeReport (PendingIntent receiver)
Ask the the system track that time the user spends in the app being launched, and
report it back once done. The report will be sent to the given receiver, with
the extras EXTRA_USAGE_TIME_REPORT
and EXTRA_USAGE_TIME_REPORT_PACKAGES
filled in.
The time interva