TtiviActivityView
A View which displays any Activity as if it were on another display.
The view will display the background until a pendingIntent is given, and again once the launched activity has finished.
If set, onStartedCallback will be called as soon as the requested activity has been successfully launched, so before it is resumed. If onFinishedCallback is set, it will be called when the started activity has finished.
Note: Call isSupported at runtime to determine whether embedding is supported by the Android platform version. When this method returns false
, using TtiviActivityView does not actually embed a view, but sends given PendingIntents as normally done in Android, switching away from the TomTom Digital Cockpit-based app. When the PendingIntent loads another activity, no control can be asserted over it: when it naturally finishes, Android is responsible to bring the user back to the initial app. As soon as the PendingIntent has been sent, the onFinishedCallback will immediately be called. The supported versions are currently SDK 28 (8.1), SDK 29 (9), SDK 30 (10), SDK 31 (11).
Note:TtiviActivityView requires a background to be set. It uses a SurfaceView to render any activity. SurfaceViews render content outside of the app's view tree. The ordering is as follows, with the user looking from the first group, down to the last one:
Surfaces with
ZOrderOnTop
flagApplication UI's view tree
Surfaces with
ZOrderMediaOverlay
flagSurfaces with no flags
Multiple Surfaces inside a group are seemingly rendered in creation order. This ordering requires the window manager to poke a hole through the view hierarchy to reveal the surfaces below. The surface used to render the user Activity might not always be filled, and therefore, to prevent visual leakage of other Surfaces, an opaque background is required to always ensure visual consistency.
The background must be a solid color, set via either:
The
background
XML attribute.By directly calling setBackground with a ColorDrawable.
By calling setBackgroundColor.
Alpha channel is not supported: the view must be opaque. Alpha level changes to the view are ignored.
Note: No control is asserted over the lifecycle of the opened activity. When closing the view, the activity might survive and be brought to front when the view is reopened.
Note: Robolectric does not support the hidden APIs used to achieve some features, which makes TtiviActivityViews only partially accessible from Robolectric-based tests.
Note:onDismissalStarted does not get called automatically. Use callOnDismissalStartedForChildActivityViews to call this method for all child views of a ViewGroup.
Constructors
Types
Properties
Callback invoked in onStarted when an activity, specified by pendingIntent, has successfully started or resumed after configuration change.
PendingIntent to launch an embedded activity. No control is asserted over the lifecycle of the started activity.
If set to true
the activity is hidden in onDismissalStarted.
Functions
This should be called, before the dismissal of the panel containing this is started.
elevation changes must be applied separately to the activity view.
visibility changes must be applied separately to the activity view.