MockContext 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.
A mock android.content.Context
class.
[Android.Runtime.Register("android/test/mock/MockContext", DoNotGenerateAcw=true)]
public class MockContext : Android.Content.Context
[<Android.Runtime.Register("android/test/mock/MockContext", DoNotGenerateAcw=true)>]
type MockContext = class
inherit Context
- Inheritance
- Attributes
Remarks
A mock android.content.Context
class. All methods are non-functional and throw java.lang.UnsupportedOperationException
. You can use this to inject other dependencies, mocks, or monitors into the classes you are testing.
Java documentation for android.test.mock.MockContext
.
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
MockContext() | |
MockContext(IntPtr, JniHandleOwnership) |
A constructor used when creating managed representations of JNI objects; called by the runtime. |
Fields
AccessibilityService |
Use with |
AccountService |
Use with |
ActivityService |
Use with |
AlarmService |
Use with |
AppOpsService |
Use with |
AppSearchService |
Use with |
AppwidgetService |
Use with |
AudioService |
Use with |
BatteryService |
Use with |
BindAllowActivityStarts |
Obsolete.
Flag for |
BindExternalServiceLong |
Works in the same way as |
BindNotPerceptible |
Obsolete.
Flag for |
BindSharedIsolatedProcess |
Obsolete.
Flag for |
BiometricService |
Use with |
BlobStoreService |
Use with |
BluetoothService |
Use with |
BugreportService |
Service to capture a bugreport. (Inherited from Context) |
CameraService |
Use with |
CaptioningService |
Use with |
CarrierConfigService |
Use with |
ClipboardService |
Use with |
CompanionDeviceService |
Use with |
ConnectivityDiagnosticsService |
Use with |
ConnectivityService |
Use with |
ConsumerIrService |
Use with |
CredentialService |
Use with |
CrossProfileAppsService |
Use with |
DeviceIdDefault |
The default device ID, which is the ID of the primary (non-virtual) device. (Inherited from Context) |
DeviceIdInvalid |
Invalid device ID. (Inherited from Context) |
DeviceLockService |
Use with |
DevicePolicyService |
Use with |
DisplayHashService |
Use with |
DisplayService |
Use with |
DomainVerificationService |
Use with |
DownloadService |
Use with |
DropboxService |
Use with |
EuiccService |
Use with |
FileIntegrityService |
Use with |
FingerprintService |
Use with |
GameService |
Use with |
GrammaticalInflectionService |
Use with |
HardwarePropertiesService |
Use with |
HealthconnectService |
Use with |
InputMethodService |
Use with |
InputService |
Use with |
IpsecService |
Use with |
JobSchedulerService |
Use with |
KeyguardService |
Use with |
LauncherAppsService |
Use with |
LayoutInflaterService |
Use with |
LocaleService |
Use with |
LocationService |
Use with |
MediaCommunicationService |
Use with |
MediaMetricsService |
Use with |
MediaProjectionService |
Use with |
MediaRouterService |
Use with |
MediaSessionService |
Use with |
MidiService |
Use with |
NetworkStatsService |
Use with |
NfcService |
Use with |
NotificationService |
Use with |
NsdService |
Use with |
OverlayService |
Use with |
PeopleService |
Use with |
PerformanceHintService |
Use with |
PowerService |
Use with |
PrintService |
|
ReceiverExported |
Obsolete.
Flag for |
ReceiverNotExported |
Obsolete.
Flag for |
ReceiverVisibleToInstantApps |
Obsolete.
Flag for |
RestrictionsService |
Use with |
RoleService |
Use with |
SearchService |
Use with |
SensorService |
Use with |
ShortcutService |
Use with |
StatusBarService |
Use with |
StorageService |
Use with |
StorageStatsService |
Use with |
SystemHealthService |
Use with |
TelecomService |
Use with |
TelephonyImsService |
Use with |
TelephonyService |
Use with |
TelephonySubscriptionService |
Use with |
TextClassificationService |
Use with |
TextServicesManagerService |
Use with |
TvInputService |
Use with |
TvInteractiveAppService |
Use with |
UiModeService |
Use with |
UsageStatsService |
Use with |
UsbService |
Use with |
UserService |
Use with |
VibratorManagerService |
Use with |
VibratorService |
Use with |
VirtualDeviceService |
Use with |
VpnManagementService |
Use with |
WallpaperService |
Use with |
WifiAwareService |
Use with |
WifiP2pService |
Use with |
WifiRttRangingService |
Use with |
WifiService |
Use with |
WindowService |
Use with |
Properties
ApplicationContext |
Return the context of the single, global Application object of the current process. |
ApplicationInfo |
Return the full application info for this context's package. |
Assets |
Return an AssetManager instance for your application's package. |
AttributionSource | (Inherited from Context) |
AttributionTag |
Attribution can be used in complex apps to logically separate parts of the app. (Inherited from Context) |
CacheDir |
Returns the absolute path to the application specific cache directory on the filesystem. |
Class |
Returns the runtime class of this |
ClassLoader |
Return a class loader you can use to retrieve classes in this package. |
CodeCacheDir |
Returns the absolute path to the application specific cache directory on the filesystem designed for storing cached code. |
ContentResolver |
Return a ContentResolver instance for your application's package. |
DataDir | |
DeviceId |
Gets the device ID this context is associated with. (Inherited from Context) |
Display |
Get the display this context is associated with. (Inherited from Context) |
ExternalCacheDir |
Returns the absolute path to the directory on the primary external filesystem (that is somewhere on ExternalStorageDirectory where the application can place cache files it owns. |
FilesDir |
Returns the absolute path to the directory on the filesystem where files created with OpenFileOutput(String, FileCreationMode) are stored. |
Handle |
The handle to the underlying Android instance. (Inherited from Object) |
IsDeviceProtectedStorage | |
IsRestricted |
Indicates whether this Context is restricted. (Inherited from Context) |
IsUiContext |
Returns |
JniIdentityHashCode | (Inherited from Object) |
JniPeerMembers | |
MainExecutor |
Return an |
MainLooper |
Return the Looper for the main thread of the current process. |
NoBackupFilesDir |
Returns the absolute path to the directory on the filesystem similar to FilesDir. |
ObbDir |
Return the primary external storage directory where this application's OBB files (if there are any) can be found. |
OpPackageName |
Return the package name that should be used for |
PackageCodePath |
Return the full path to this context's primary Android package. |
PackageManager |
Return PackageManager instance to find global package information. |
PackageName |
Return the name of this application's package. |
PackageResourcePath |
Return the full path to this context's primary Android package. |
Params |
Return the set of parameters which this Context was created with, if it
was created via |
PeerReference | (Inherited from Object) |
Resources |
Return a Resources instance for your application's package. |
Theme |
Return the Theme object associated with this Context. |
ThresholdClass |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
ThresholdType |
This API supports the Mono for Android infrastructure and is not intended to be used directly from your code. |
Wallpaper | |
WallpaperDesiredMinimumHeight | |
WallpaperDesiredMinimumWidth |
Methods
BindService(Intent, Bind, IExecutor, IServiceConnection) |
Same as |
BindService(Intent, Context+BindServiceFlags, IExecutor, IServiceConnection) | (Inherited from Context) |
BindService(Intent, IServiceConnection, Bind) |
Connect to an application service, creating it if needed. |
BindService(Intent, IServiceConnection, Context+BindServiceFlags) | (Inherited from Context) |
BindServiceAsUser(Intent, IServiceConnection, Context+BindServiceFlags, UserHandle) | (Inherited from Context) |
BindServiceAsUser(Intent, IServiceConnection, Int32, UserHandle) |
Binds to a service in the given |
CheckCallingOrSelfPermission(String) |
Determine whether the calling process of an IPC or you have been granted a particular permission. |
CheckCallingOrSelfUriPermission(Uri, ActivityFlags) |
Determine whether the calling process of an IPC or you has been granted permission to access a specific URI. |
CheckCallingOrSelfUriPermissions(IList<Uri>, Int32) |
Determine whether the calling process of an IPC <em>or you</em> has been granted permission to access a list of URIs. (Inherited from Context) |
CheckCallingPermission(String) |
Determine whether the calling process of an IPC you are handling has been granted a particular permission. |
CheckCallingUriPermission(Uri, ActivityFlags) |
Determine whether the calling process and user ID has been granted permission to access a specific URI. |
CheckCallingUriPermissions(IList<Uri>, Int32) |
Determine whether the calling process and user ID has been granted permission to access a list of URIs. (Inherited from Context) |
CheckPermission(String, Int32, Int32) |
Determine whether the given permission is allowed for a particular process and user ID running in the system. |
CheckSelfPermission(String) | |
CheckUriPermission(Uri, Int32, Int32, ActivityFlags) |
Determine whether a particular process and user ID has been granted permission to access a specific URI. |
CheckUriPermission(Uri, String, String, Int32, Int32, ActivityFlags) |
Check both a Uri and normal permission. |
CheckUriPermissions(IList<Uri>, Int32, Int32, Int32) |
Determine whether a particular process and user ID has been granted permission to access a list of URIs. (Inherited from Context) |
ClearWallpaper() | |
Clone() |
Creates and returns a copy of this object. (Inherited from Object) |
CreateAttributionContext(String) |
Return a new Context object for the current Context but attribute to a different tag. (Inherited from Context) |
CreateConfigurationContext(Configuration) |
Return a new Context object for the current Context but whose resources are adjusted to match the given Configuration. |
CreateContext(ContextParams) |
Creates a context with specific properties and behaviors. (Inherited from Context) |
CreateContextForSplit(String) | |
CreateDeviceContext(Int32) |
Returns a new |
CreateDeviceProtectedStorageContext() | |
CreateDisplayContext(Display) |
Return a new Context object for the current Context but whose resources are adjusted to match the metrics of the given Display. |
CreatePackageContext(String, PackageContextFlags) |
Return a new Context object for the given application name. |
CreateWindowContext(Display, Int32, Bundle) |
Creates a |
CreateWindowContext(Int32, Bundle) |
Creates a Context for a non-activity window. (Inherited from Context) |
DatabaseList() |
Returns an array of strings naming the private databases associated with this Context's application package. |
DeleteDatabase(String) |
Delete an existing private SQLiteDatabase associated with this Context's application package. |
DeleteFile(String) |
Delete the given private file associated with this Context's application package. |
DeleteSharedPreferences(String) | |
Dispose() | (Inherited from Object) |
Dispose(Boolean) | (Inherited from Object) |
EnforceCallingOrSelfPermission(String, String) |
If neither you nor the calling process of an IPC you are handling has been granted a particular permission, throw a SecurityException. |
EnforceCallingOrSelfUriPermission(Uri, ActivityFlags, String) |
If the calling process of an IPC or you has not been granted permission to access a specific URI, throw SecurityException. |
EnforceCallingPermission(String, String) |
If the calling process of an IPC you are handling has not been granted a particular permission, throw a SecurityException. |
EnforceCallingUriPermission(Uri, ActivityFlags, String) |
If the calling process and user ID has not been granted permission to access a specific URI, throw SecurityException. |
EnforcePermission(String, Int32, Int32, String) |
If the given permission is not allowed for a particular process and user ID running in the system, throw a SecurityException. |
EnforceUriPermission(Uri, Int32, Int32, ActivityFlags, String) |
If a particular process and user ID has not been granted permission to access a specific URI, throw SecurityException. |
EnforceUriPermission(Uri, String, String, Int32, Int32, ActivityFlags, String) |
Enforce both a Uri and normal permission. |
Equals(Object) |
Indicates whether some other object is "equal to" this one. (Inherited from Object) |
FileList() |
Returns an array of strings naming the private files associated with this Context's application package. |
GetColor(Int32) |
Returns a color associated with a particular resource ID and styled for the current theme. (Inherited from Context) |
GetColorStateList(Int32) |
Returns a color state list associated with a particular resource ID and styled for the current theme. (Inherited from Context) |
GetDatabasePath(String) | |
GetDir(String, FileCreationMode) |
Retrieve, creating if needed, a new directory in which the application can place its own custom data files. |
GetDrawable(Int32) |
Returns a drawable object associated with a particular resource ID and styled for the current theme. (Inherited from Context) |
GetExternalCacheDirs() |
Returns absolute paths to application-specific directories on all external storage devices where the application can place cache files it owns. |
GetExternalFilesDir(String) |
Returns the absolute path to the directory on the primary external filesystem (that is somewhere on ExternalStorageDirectory) where the application can place persistent files it owns. |
GetExternalFilesDirs(String) |
Returns absolute paths to application-specific directories on all external storage devices where the application can place persistent files it owns. |
GetExternalMediaDirs() |
Obsolete.
Returns absolute paths to application-specific directories on all external storage devices where the application can place media files. |
GetFileStreamPath(String) |
Returns the absolute path on the filesystem where a file created with OpenFileOutput(String, FileCreationMode) is stored. |
GetHashCode() |
Returns a hash code value for the object. (Inherited from Object) |
GetObbDirs() |
Returns absolute paths to application-specific directories on all external storage devices where the application's OBB files (if there are any) can be found. |
GetSharedPreferences(String, FileCreationMode) |
Retrieve and hold the contents of the preferences file 'name', returning a SharedPreferences through which you can retrieve and modify its values. |
GetString(Int32, Object[]) |
Returns a localized string from the application's package's default string table. (Inherited from Context) |
GetString(Int32) |
Returns a localized string from the application's package's default string table. (Inherited from Context) |
GetSystemService(Class) |
Return the handle to a system-level service by class. (Inherited from Context) |
GetSystemService(String) |
Return the handle to a system-level service by name. |
GetSystemServiceName(Class) | |
GetText(Int32) |
Return a localized, styled CharSequence from the application's package's default string table. (Inherited from Context) |
GetTextFormatted(Int32) |
Return a localized, styled CharSequence from the application's package's default string table. (Inherited from Context) |
GrantUriPermission(String, Uri, ActivityFlags) |
Grant permission to access a specific Uri to another package, regardless of whether that package has general permission to access the Uri's content provider. |
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) |
MoveDatabaseFrom(Context, String) | |
MoveSharedPreferencesFrom(Context, String) | |
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) |
ObtainStyledAttributes(IAttributeSet, Int32[], Int32, Int32) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
ObtainStyledAttributes(IAttributeSet, Int32[]) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
ObtainStyledAttributes(Int32, Int32[]) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
ObtainStyledAttributes(Int32[]) |
Retrieve styled attribute information in this Context's theme. (Inherited from Context) |
OpenFileInput(String) |
Open a private file associated with this Context's application package for reading. |
OpenFileOutput(String, FileCreationMode) |
Open a private file associated with this Context's application package for writing. |
OpenOrCreateDatabase(String, FileCreationMode, SQLiteDatabase+ICursorFactory, IDatabaseErrorHandler) |
Open a new private SQLiteDatabase associated with this Context's application package. |
OpenOrCreateDatabase(String, FileCreationMode, SQLiteDatabase+ICursorFactory) |
Open a new private SQLiteDatabase associated with this Context's application package. |
PeekWallpaper() | |
RegisterComponentCallbacks(IComponentCallbacks) |
Add a new |
RegisterDeviceIdChangeListener(IExecutor, IIntConsumer) |
Adds a new device ID changed listener to the |
RegisterReceiver(BroadcastReceiver, IntentFilter, ActivityFlags) | |
RegisterReceiver(BroadcastReceiver, IntentFilter, ReceiverFlags) | (Inherited from Context) |
RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ActivityFlags) | |
RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler, ReceiverFlags) | (Inherited from Context) |
RegisterReceiver(BroadcastReceiver, IntentFilter, String, Handler) |
Register to receive intent broadcasts, to run in the context of scheduler. |
RegisterReceiver(BroadcastReceiver, IntentFilter) |
Register a BroadcastReceiver to be run in the main activity thread. |
RemoveStickyBroadcast(Intent) | |
RemoveStickyBroadcastAsUser(Intent, UserHandle) | |
RevokeSelfPermissionOnKill(String) |
Triggers the asynchronous revocation of a runtime permission. (Inherited from Context) |
RevokeSelfPermissionsOnKill(ICollection<String>) |
Triggers the revocation of one or more permissions for the calling package. (Inherited from Context) |
RevokeUriPermission(String, Uri, ActivityFlags) | |
RevokeUriPermission(Uri, ActivityFlags) |
Remove all permissions to access a particular content provider Uri that were previously added with M:Android.Content.Context.GrantUriPermission(System.String,Android.Net.Uri,Android.Net.Uri). |
SendBroadcast(Intent, String, Bundle) |
Broadcast the given intent to all interested BroadcastReceivers, allowing an optional required permission to be enforced. (Inherited from Context) |
SendBroadcast(Intent, String) |
Broadcast the given intent to all interested BroadcastReceivers, allowing an optional required permission to be enforced. |
SendBroadcast(Intent) |
Broadcast the given intent to all interested BroadcastReceivers. |
SendBroadcastAsUser(Intent, UserHandle, String) |
Version of SendBroadcast(Intent, String) that allows you to specify the user the broadcast will be sent to. |
SendBroadcastAsUser(Intent, UserHandle) |
Version of SendBroadcast(Intent) that allows you to specify the user the broadcast will be sent to. |
SendBroadcastWithMultiplePermissions(Intent, String[]) |
Broadcast the given intent to all interested BroadcastReceivers, allowing an array of required permissions to be enforced. (Inherited from Context) |
SendOrderedBroadcast(Intent, String, BroadcastReceiver, Handler, Result, String, Bundle) |
Version of SendBroadcast(Intent) that allows you to receive data back from the broadcast. |
SendOrderedBroadcast(Intent, String, Bundle, BroadcastReceiver, Handler, Result, String, Bundle) |
Version of |
SendOrderedBroadcast(Intent, String, Bundle) |
Broadcast the given intent to all interested BroadcastReceivers, delivering them one at a time to allow more preferred receivers to consume the broadcast before it is delivered to less preferred receivers. (Inherited from Context) |
SendOrderedBroadcast(Intent, String, String, BroadcastReceiver, Handler, Result, String, Bundle) |
Version of
|
SendOrderedBroadcast(Intent, String) | |
SendOrderedBroadcastAsUser(Intent, UserHandle, String, BroadcastReceiver, Handler, Result, String, Bundle) | |
SendStickyBroadcast(Intent, Bundle) |
Perform a |
SendStickyBroadcast(Intent) | |
SendStickyBroadcastAsUser(Intent, UserHandle) | |
SendStickyOrderedBroadcast(Intent, BroadcastReceiver, Handler, Result, String, Bundle) | |
SendStickyOrderedBroadcastAsUser(Intent, UserHandle, BroadcastReceiver, Handler, Result, String, Bundle) | |
SetHandle(IntPtr, JniHandleOwnership) |
Sets the Handle property. (Inherited from Object) |
SetTheme(Int32) |
Set the base theme for this context. |
SetWallpaper(Bitmap) | |
SetWallpaper(Stream) | |
StartActivities(Intent[], Bundle) |
Launch multiple new activities. |
StartActivities(Intent[]) |
Same as StartActivities(Intent[], Bundle) with no options specified. |
StartActivity(Intent, Bundle) |
Launch a new activity. |
StartActivity(Intent) |
Same as StartActivity(Intent, Bundle) with no options specified. |
StartActivity(Type) | (Inherited from Context) |
StartForegroundService(Intent) | |
StartInstrumentation(ComponentName, String, Bundle) |
Start executing an Instrumentation class. |
StartIntentSender(IntentSender, Intent, ActivityFlags, ActivityFlags, Int32, Bundle) |
Like StartActivity(Intent, Bundle), but taking a IntentSender to start. |
StartIntentSender(IntentSender, Intent, ActivityFlags, ActivityFlags, Int32) | |
StartService(Intent) |
Request that a given application service be started. |
StopService(Intent) |
Request that a given application service be stopped. |
ToArray<T>() | (Inherited from Object) |
ToString() |
Returns a string representation of the object. (Inherited from Object) |
UnbindService(IServiceConnection) |
Disconnect from an application service. |
UnregisterComponentCallbacks(IComponentCallbacks) |
Remove a |
UnregisterDeviceIdChangeListener(IIntConsumer) |
Removes a device ID changed listener from the Context. (Inherited from Context) |
UnregisterFromRuntime() | (Inherited from Object) |
UnregisterReceiver(BroadcastReceiver) |
Unregister a previously registered BroadcastReceiver. |
UpdateServiceGroup(IServiceConnection, Int32, Int32) |
For a service previously bound with |
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) |
Explicit Interface Implementations
IJavaPeerable.Disposed() | (Inherited from Object) |
IJavaPeerable.DisposeUnlessReferenced() | (Inherited from Object) |
IJavaPeerable.Finalized() | (Inherited from Object) |
IJavaPeerable.JniManagedPeerState | (Inherited from Object) |
IJavaPeerable.SetJniIdentityHashCode(Int32) | (Inherited from Object) |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) | (Inherited from Object) |
IJavaPeerable.SetPeerReference(JniObjectReference) | (Inherited from Object) |
Extension Methods
JavaCast<TResult>(IJavaObject) |
Performs an Android runtime-checked type conversion. |
JavaCast<TResult>(IJavaObject) | |
GetJniTypeName(IJavaPeerable) |