Presentation Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Base class for presentations.
[Android.Runtime.Register("android/app/Presentation", DoNotGenerateAcw=true)]
public class Presentation : Android.App.Dialog
[<Android.Runtime.Register("android/app/Presentation", DoNotGenerateAcw=true)>]
type Presentation = class
inherit Dialog
- Inheritance
- Attributes
Remarks
Base class for presentations. A presentation is a special kind of dialog whose purpose is to present content on another display. While traditionally used for external displays, starting from Build.VERSION_CODES.BAKLAVA, Display.FLAG_PRESENTATION can now also be attached to built-in internal displays, allowing presentations to be shown on them as well. On earlier releases, internal displays were not suitable for presentations and attempting to show one would always result in an exception. A Presentation is associated with the target Display at creation time and configures its context and resource configuration according to the display's metrics.
Notably, the Context of a presentation is different from the context of its containing Activity. It is important to inflate the layout of a presentation and load other resources using the presentation's own context to ensure that assets of the correct size and density for the target display are loaded.
A presentation is automatically canceled (see Dialog.cancel()) when the display to which it is attached is removed or when the application's associated task is removed. An activity should take care of pausing and resuming whatever content is playing within the presentation whenever the activity itself is paused or resumed.
Before showing a Presentation it's important to choose the Display on which it will appear. Choosing a presentation display is sometimes difficult because there may be multiple displays attached. Rather than trying to guess which display is best, an application should let the system choose a suitable presentation display.
There are two main ways to choose a Display.
The easiest way to choose a presentation display is to use the MediaRouter API. The media router service keeps track of which audio and video routes are available on the system. The media router sends notifications whenever routes are selected or unselected or when the preferred presentation display of a route changes. So an application can simply watch for these notifications and show or dismiss a presentation on the preferred presentation display automatically.
The preferred presentation display is the display that the media router recommends that the application should use if it wants to show content on another display. Sometimes there may not be a preferred presentation display in which case the application should show its content locally without using a presentation.
Here's how to use the media router to create and show a presentation on the preferred presentation display using MediaRouter.RouteInfo.getPresentationDisplay().
The following sample code from ApiDemos demonstrates how to use the media router to automatically switch between showing content in the application's activity and showing the content in a presentation when a presentation display is available.
Another way to choose a presentation display is to use the DisplayManager API directly. The display manager service provides functions to enumerate and describe all displays that are attached to the system including displays that may be used for presentations.
The display manager keeps track of all displays in the system. However, not all displays are appropriate for showing presentations. For example, a presentation is disallowed on the same display as the application's top visible task to prevent it from obscuring its own content. Additionally, presentations on internal displays are restricted and may require the application's task to be focused on a different display to ensure the user is actively interacting with the application. Violating these rules will result in WindowManager.InvalidDisplayException being thrown when invoking show(). If the conditions for showing a presentation are no longer met while it is already visible, the system will automatically dismiss it and the application will receive the onStop() callback. When shown, a presentation will occlude other activities on the target display for security reasons.
Here's how to identify suitable displays for showing presentations using DisplayManager.getDisplays(String) and the DisplayManager.DISPLAY_CATEGORY_PRESENTATION category.
The following sample code from ApiDemos demonstrates how to use the display manager to enumerate displays and show content on multiple presentation displays simultaneously.
Android reference for android.app.Presentation.
Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.
Constructors
| Name | Description |
|---|---|
| Presentation(Context, Display, Int32) |
Creates a new presentation that is attached to the specified display using the optionally specified theme. |
| Presentation(Context, Display) |
Creates a new presentation that is attached to the specified display using the default theme. |
| Presentation(IntPtr, JniHandleOwnership) |
Initializes a managed representation of an existing Java Native Interface object. |
Properties
| Name | Description |
|---|---|
| ActionBar |
Retrieve the ActionBar attached to this dialog, if present. (Inherited from Dialog) |
| Class |
Returns the runtime class of this |
| Context |
Retrieve the Context this Dialog is running in. (Inherited from Dialog) |
| CurrentFocus |
Call Window.getCurrentFocus() on the Window if this Activity to return the currently focused view. (Inherited from Dialog) |
| Display |
Gets the Display that this presentation appears on. |
| Handle |
The handle to the underlying Android instance. (Inherited from Object) |
| IsShowing | (Inherited from Dialog) |
| JniIdentityHashCode |
Gets the identity hash code assigned to this Java peer by the interop runtime. (Inherited from Object) |
| JniManagedPeerState | (Inherited from JavaObject) |
| JniPeerMembers |
Provides JNI binding infrastructure for Android.App.Presentation. |
| LayoutInflater | (Inherited from Dialog) |
| OnBackInvokedDispatcher |
Returns the OnBackInvokedDispatcher instance associated with the window that this dialog is attached to. (Inherited from Dialog) |
| OwnerActivity |
Returns the Activity that owns this Dialog. (Inherited from Dialog) |
| PeerReference |
Gets the JNI object reference for this Java peer. (Inherited from Object) |
| Resources |
Gets the Resources that should be used to inflate the layout of this presentation. |
| SearchEvent |
During the onSearchRequested() callbacks, this function will return the SearchEvent that triggered the callback, if it exists. (Inherited from Dialog) |
| ThresholdClass |
Provides JNI binding infrastructure for Android.App.Presentation. |
| ThresholdType |
Provides JNI binding infrastructure for Android.App.Presentation. |
| VolumeControlStream |
See also: (Inherited from Dialog) |
| Window |
Retrieve the current Window for the activity. (Inherited from Dialog) |
Methods
| Name | Description |
|---|---|
| AddContentView(View, ViewGroup+LayoutParams) |
Add an additional content view to the screen. (Inherited from Dialog) |
| Cancel() |
Cancel the dialog. (Inherited from Dialog) |
| Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
| CloseOptionsMenu() |
See also: (Inherited from Dialog) |
| Construct(JniObjectReference, JniObjectReferenceOptions) | (Inherited from JavaObject) |
| Create() |
Forces immediate creation of the dialog. (Inherited from Dialog) |
| Dismiss() |
Dismiss this dialog, removing it from the screen. (Inherited from Dialog) |
| DispatchGenericMotionEvent(MotionEvent) |
Called to process generic motion events. (Inherited from Dialog) |
| DispatchKeyEvent(KeyEvent) |
Called to process key events. (Inherited from Dialog) |
| DispatchKeyShortcutEvent(KeyEvent) |
Called to process a key shortcut event. (Inherited from Dialog) |
| DispatchPopulateAccessibilityEvent(AccessibilityEvent) |
Called to process population of AccessibilityEvents. (Inherited from Dialog) |
| DispatchTouchEvent(MotionEvent) |
Called to process touch screen events. (Inherited from Dialog) |
| DispatchTrackballEvent(MotionEvent) |
Called to process trackball events. (Inherited from Dialog) |
| Dispose() |
Releases the resources held by this Java peer. (Inherited from Object) |
| Dispose(Boolean) |
Releases the resources held by this Java peer. (Inherited from Object) |
| DisposeUnlessReferenced() | (Inherited from JavaObject) |
| Equals(Object) | (Inherited from JavaObject) |
| Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
| FindViewById(Int32) |
Finds the first descendant view with the given ID or null if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via show() or create()). (Inherited from Dialog) |
| FindViewById<T>(Int32) | (Inherited from Dialog) |
| GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
| Hide() |
Hide the dialog, but do not dismiss it. (Inherited from Dialog) |
| InvalidateOptionsMenu() |
See also: (Inherited from Dialog) |
| JavaFinalize() |
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object. (Inherited from Object) |
| Notify() |
Wakes up a single thread that is waiting on this object's monitor. (Inherited from Object) |
| NotifyAll() |
Wakes up all threads that are waiting on this object's monitor. (Inherited from Object) |
| OnActionModeFinished(ActionMode) |
Called when an action mode has been finished. (Inherited from Dialog) |
| OnActionModeStarted(ActionMode) |
Called when an action mode has been started. (Inherited from Dialog) |
| OnAttachedToWindow() |
Called when the window has been attached to the window manager. (Inherited from Dialog) |
| OnBackPressed() |
This method was deprecated in API level 33. (Inherited from Dialog) |
| OnContentChanged() |
This hook is called whenever the content view of the screen changes (due to a call to Window.setContentView or Window.addContentView). (Inherited from Dialog) |
| OnContextItemSelected(IMenuItem) |
See also: (Inherited from Dialog) |
| OnContextMenuClosed(IMenu) |
See also: (Inherited from Dialog) |
| OnCreate(Bundle) |
Similar to Activity.onCreate, you should initialize your dialog in this method, including calling setContentView(View). (Inherited from Dialog) |
| OnCreateContextMenu(IContextMenu, View, IContextMenuContextMenuInfo) |
Called when the context menu for this view is being built. (Inherited from Dialog) |
| OnCreateOptionsMenu(IMenu) |
It is usually safe to proxy this call to the owner activity's Activity.onCreateOptionsMenu(Menu) if the client desires the same menu for this Dialog. (Inherited from Dialog) |
| OnCreatePanelMenu(Int32, IMenu) |
Initialize the contents of the menu for panel 'featureId'. (Inherited from Dialog) |
| OnCreatePanelView(Int32) |
Instantiate the view to display in the panel for 'featureId'. (Inherited from Dialog) |
| OnDetachedFromWindow() |
Called when the window has been detached from the window manager. (Inherited from Dialog) |
| OnDisplayChanged() |
Called by the system when the properties of the Display to which the presentation is attached have changed. |
| OnDisplayRemoved() |
Called by the system when the Display to which the presentation is attached has been removed. |
| OnGenericMotionEvent(MotionEvent) |
Called when a generic motion event was not handled by any of the views inside of the dialog. (Inherited from Dialog) |
| OnKeyDown(Keycode, KeyEvent) |
A key was pressed down. (Inherited from Dialog) |
| OnKeyLongPress(Keycode, KeyEvent) |
Default implementation of KeyEvent.Callback.onKeyLongPress(): always returns false (doesn't handle the event). (Inherited from Dialog) |
| OnKeyMultiple(Keycode, Int32, KeyEvent) |
Default implementation of KeyEvent.Callback.onKeyMultiple(): always returns false (doesn't handle the event). (Inherited from Dialog) |
| OnKeyShortcut(Keycode, KeyEvent) |
Called when a key shortcut event is not handled by any of the views in the Dialog. (Inherited from Dialog) |
| OnKeyUp(Keycode, KeyEvent) |
A key was released. (Inherited from Dialog) |
| OnMenuItemSelected(Int32, IMenuItem) |
Called when a panel's menu item has been selected by the user. (Inherited from Dialog) |
| OnMenuOpened(Int32, IMenu) |
Called when a panel's menu is opened by the user. (Inherited from Dialog) |
| OnOptionsItemSelected(IMenuItem) |
See also: (Inherited from Dialog) |
| OnOptionsMenuClosed(IMenu) |
See also: (Inherited from Dialog) |
| OnPanelClosed(Int32, IMenu) |
Called when a panel is being closed. (Inherited from Dialog) |
| OnPrepareOptionsMenu(IMenu) |
It is usually safe to proxy this call to the owner activity's Activity.onPrepareOptionsMenu(Menu) if the client desires the same menu for this Dialog. (Inherited from Dialog) |
| OnPreparePanel(Int32, View, IMenu) |
Prepare a panel to be displayed. (Inherited from Dialog) |
| OnRestoreInstanceState(Bundle) |
Restore the state of the dialog from a previously saved bundle. (Inherited from Dialog) |
| OnSaveInstanceState() |
Saves the state of the dialog into a bundle. (Inherited from Dialog) |
| OnSearchRequested() |
This hook is called when the user signals the desire to start a search. (Inherited from Dialog) |
| OnSearchRequested(SearchEvent) |
This hook is called when the user signals the desire to start a search. (Inherited from Dialog) |
| OnStart() |
Called when the dialog is starting. (Inherited from Dialog) |
| OnStop() |
Called to tell you that you're stopping. (Inherited from Dialog) |
| OnTouchEvent(MotionEvent) |
Called when a touch screen event was not handled by any of the views under it. (Inherited from Dialog) |
| OnTrackballEvent(MotionEvent) |
Called when the trackball was moved and not handled by any of the views inside of the activity. (Inherited from Dialog) |
| OnWindowAttributesChanged(WindowManagerLayoutParams) |
This is called whenever the current window attributes change. (Inherited from Dialog) |
| OnWindowFocusChanged(Boolean) |
This hook is called whenever the window focus changes. (Inherited from Dialog) |
| OnWindowStartingActionMode(ActionMode+ICallback, ActionModeType) |
Called when an action mode is being started for this window. (Inherited from Dialog) |
| OnWindowStartingActionMode(ActionMode+ICallback) |
Called when an action mode is being started for this window. (Inherited from Dialog) |
| OpenContextMenu(View) |
See also: (Inherited from Dialog) |
| OpenOptionsMenu() |
See also: (Inherited from Dialog) |
| RegisterForContextMenu(View) |
See also: (Inherited from Dialog) |
| RequestWindowFeature(Int32) |
Enable extended window features. (Inherited from Dialog) |
| RequireViewById(Int32) |
Finds the first descendant view with the given ID or throws an IllegalArgumentException if the ID is invalid (< 0), there is no matching view in the hierarchy, or the dialog has not yet been fully created (for example, via show() or create()). (Inherited from Dialog) |
| SetCancelable(Boolean) |
Sets whether this dialog is cancelable with the BACK key. (Inherited from Dialog) |
| SetCanceledOnTouchOutside(Boolean) |
Sets whether this dialog is canceled when touched outside the window's bounds. (Inherited from Dialog) |
| SetCancelMessage(Message) |
Set a message to be sent when the dialog is canceled. (Inherited from Dialog) |
| SetContentView(Int32) |
Set the screen content from a layout resource. (Inherited from Dialog) |
| SetContentView(View, ViewGroup+LayoutParams) |
Set the screen content to an explicit view. (Inherited from Dialog) |
| SetContentView(View) |
Set the screen content to an explicit view. (Inherited from Dialog) |
| SetDismissMessage(Message) |
Set a message to be sent when the dialog is dismissed. (Inherited from Dialog) |
| SetFeatureDrawable(Int32, Drawable) |
Convenience for calling android.view.Window.setFeatureDrawable(int,Drawable). (Inherited from Dialog) |
| SetFeatureDrawableAlpha(Int32, Int32) |
Convenience for calling Window.setFeatureDrawableAlpha(int, int). (Inherited from Dialog) |
| SetFeatureDrawableResource(Int32, Int32) |
Convenience for calling Window.setFeatureDrawableResource(int, int). (Inherited from Dialog) |
| SetFeatureDrawableUri(Int32, Uri) |
Convenience for calling Window.setFeatureDrawableUri(int, Uri). (Inherited from Dialog) |
| SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
| SetOnCancelListener(IDialogInterfaceOnCancelListener) |
Set a listener to be invoked when the dialog is canceled. (Inherited from Dialog) |
| SetOnDismissListener(IDialogInterfaceOnDismissListener) |
Set a listener to be invoked when the dialog is dismissed. (Inherited from Dialog) |
| SetOnKeyListener(IDialogInterfaceOnKeyListener) |
Sets the callback that will be called if a key is dispatched to the dialog. (Inherited from Dialog) |
| SetOnShowListener(IDialogInterfaceOnShowListener) |
Sets a listener to be invoked when the dialog is shown. (Inherited from Dialog) |
| SetPeerReference(JniObjectReference, JniObjectReferenceOptions) | (Inherited from JavaObject) |
| SetTitle(ICharSequence) |
Set the title text for this dialog's window. (Inherited from Dialog) |
| SetTitle(Int32) |
Set the title text for this dialog's window. (Inherited from Dialog) |
| SetTitle(String) |
Set the title text for this dialog's window. (Inherited from Dialog) |
| Show() |
Start the dialog and display it on screen. (Inherited from Dialog) |
| TakeKeyEvents(Boolean) |
Request that key events come to this dialog. (Inherited from Dialog) |
| ToArray<T>() |
Creates a managed array from this Java array wrapper. (Inherited from Object) |
| ToString() |
Returns a string representation of the object. (Inherited from Object) |
| UnregisterForContextMenu(View) |
See also: (Inherited from Dialog) |
| UnregisterFromRuntime() |
Unregisters this Java peer from the interop runtime. (Inherited from Object) |
| Wait() |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>. (Inherited from Object) |
| Wait(Int64, Int32) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
| Wait(Int64) |
Causes the current thread to wait until it is awakened, typically by being <em>notified</em> or <em>interrupted</em>, or until a certain amount of real time has elapsed. (Inherited from Object) |
Events
| Name | Description |
|---|---|
| CancelEvent | (Inherited from Dialog) |
| DismissEvent | (Inherited from Dialog) |
| KeyPress | (Inherited from Dialog) |
| ShowEvent | (Inherited from Dialog) |
Explicit Interface Implementations
| Name | Description |
|---|---|
| IJavaPeerable.Disposed() | (Inherited from JavaObject) |
| IJavaPeerable.Finalized() | (Inherited from JavaObject) |
| IJavaPeerable.JniObjectReferenceControlBlock | (Inherited from JavaObject) |
| IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from JavaObject) |
| IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from JavaObject) |
| IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from JavaObject) |
| IJavaPeerable.UnregisterFromRuntime() | (Inherited from Dialog) |
Extension Methods
| Name | Description |
|---|---|
| GetJniTypeName(IJavaPeerable) |
Gets the JNI name of the type of the instance |
| JavaAs<TResult>(IJavaPeerable) |
Try to coerce |
| JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
| JavaCast<TResult>(IJavaObject) | |
| TryJavaCast<TResult>(IJavaPeerable, TResult) |
Try to coerce |