共用方式為


Context.CreateDeviceContext(Int32) Method

Definition

Returns a new Context object from the current context but with device association given by the deviceId.

[Android.Runtime.Register("createDeviceContext", "(I)Landroid/content/Context;", "GetCreateDeviceContext_IHandler", ApiSince=34)]
public virtual Android.Content.Context CreateDeviceContext (int deviceId);
[<Android.Runtime.Register("createDeviceContext", "(I)Landroid/content/Context;", "GetCreateDeviceContext_IHandler", ApiSince=34)>]
abstract member CreateDeviceContext : int -> Android.Content.Context
override this.CreateDeviceContext : int -> Android.Content.Context

Parameters

deviceId
Int32

The ID of the device to associate with this context.

Returns

A context associated with the given device ID.

Attributes

Remarks

Returns a new Context object from the current context but with device association given by the deviceId. 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.

Applications that run on virtual devices may use this method to access the default device capabilities and functionality (by passing Context#DEVICE_ID_DEFAULT. Similarly, applications running on the default device may access the functionality of virtual devices.

Note that the newly created instance will be associated with the same display as the parent Context, regardless of the device ID passed here.

Java documentation for android.content.Context.createDeviceContext(int).

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