Android.Test.Mock.MockContext.CreatePackageContext Method
Return a new Context object for the given application name.

Syntax

[Android.Runtime.Register("createPackageContext", "(Ljava/lang/String;I)Landroid/content/Context;", "GetCreatePackageContext_Ljava_lang_String_IHandler")]
public override Android.Content.Context CreatePackageContext (string packageName, [Android.Runtime.GeneratedEnum] Android.Content.PackageContextFlags flags)

Parameters

packageName
Name of the application's package.
flags
Option flags, one of Android.Content.Context.CONTEXT_INCLUDE_CODE or Android.Content.Context.CONTEXT_IGNORE_SECURITY.

Returns

Documentation for this section has not yet been entered.

Exceptions

TypeReason
!:NoType:android/content/pm/PackageManager$NameNotFoundException;Href=../../../../reference/android/content/pm/PackageManager.NameNotFoundException.html

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 NoType:android/content/pm/PackageManager$NameNotFoundException;Href=../../../../reference/android/content/pm/PackageManager.NameNotFoundException.html 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 Android.Content.Context.CONTEXT_INCLUDE_CODE for more information}.

[Android Documentation]

Requirements

Namespace: Android.Test.Mock
Assembly: Mono.Android (in Mono.Android.dll)
Assembly Versions: 0.0.0.0
Since: Added in API level 1