Megosztás a következőn keresztül:


Context.CreatePackageContext(String, PackageContextFlags) Method

Definition

Return a new Context object for the given application name.

[Android.Runtime.Register("createPackageContext", "(Ljava/lang/String;I)Landroid/content/Context;", "GetCreatePackageContext_Ljava_lang_String_IHandler")]
public abstract Android.Content.Context? CreatePackageContext (string? packageName, Android.Content.PackageContextFlags flags);
[<Android.Runtime.Register("createPackageContext", "(Ljava/lang/String;I)Landroid/content/Context;", "GetCreatePackageContext_Ljava_lang_String_IHandler")>]
abstract member CreatePackageContext : string * Android.Content.PackageContextFlags -> Android.Content.Context

Parameters

packageName
String

Name of the application's package.

flags
PackageContextFlags

Option flags.

Returns

A Context for the application.

Attributes

Exceptions

Remarks

Return a new Context object for the given application name. This Context is the same as what the named application gets when it is launched, containing the same resources and class loader. Each call to this method returns a new instance of a Context object; Context objects are not shared, however they share common state (Resources, ClassLoader, etc) so the Context instance itself is fairly lightweight.

Throws android.content.pm.PackageManager.NameNotFoundException if there is no application with the given package name.

Throws java.lang.SecurityException if the Context requested can not be loaded into the caller's process for security reasons (see #CONTEXT_INCLUDE_CODE for more information}.

Java documentation for android.content.Context.createPackageContext(java.lang.String, 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