Share via


Context.CreateDisplayContext(Display) Method

Definition

Returns a new Context object from the current context but with resources adjusted to match the metrics of display.

[Android.Runtime.Register("createDisplayContext", "(Landroid/view/Display;)Landroid/content/Context;", "GetCreateDisplayContext_Landroid_view_Display_Handler")]
public abstract Android.Content.Context? CreateDisplayContext (Android.Views.Display display);
[<Android.Runtime.Register("createDisplayContext", "(Landroid/view/Display;)Landroid/content/Context;", "GetCreateDisplayContext_Landroid_view_Display_Handler")>]
abstract member CreateDisplayContext : Android.Views.Display -> Android.Content.Context

Parameters

display
Display

The display to which the current context's resources are adjusted.

Returns

A context for the display.

Attributes

Remarks

Returns a new Context object from the current context but with resources adjusted to match the metrics of display. Each call to this method returns a new instance of a context object. Context objects are not shared; however, common state (such as the ClassLoader and other resources for the same configuration) can be shared, so the Context itself is lightweight.

<b>Note:</b> This Context is <b>not</b> expected to be updated with new configuration if the underlying display configuration changes and the cached Resources it returns could be stale. It is suggested to use android.hardware.display.DisplayManager.DisplayListener to listen for changes and re-create an instance if necessary.

This Context is <b>not</b> a UI context, do not use it to access UI components or obtain a WindowManager instance.

To obtain an instance of WindowManager configured to show windows on the given display, call #createWindowContext(int, Bundle) on the returned display context, then call #getSystemService(String) or #getSystemService(Class) on the returned window context.

Java documentation for android.content.Context.createDisplayContext(android.view.Display).

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.

Applies to