MockContext 类
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
模拟 android.content.Context
类。
[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
- 继承
- 属性
注解
模拟 android.content.Context
类。 所有方法都不起作用,并引发 java.lang.UnsupportedOperationException
。 可以使用此功能将其他依赖项、模拟或监视器注入要测试的类中。
的 android.test.mock.MockContext
Java 文档。
此页面的部分内容是基于 创建和共享的工作进行的修改,并根据 署名许可中所述的术语使用。
构造函数
MockContext() | |
MockContext(IntPtr, JniHandleOwnership) |
创建 JNI 对象的托管表示形式时使用的构造函数;由运行时调用。 |
字段
AccessibilityService |
使用 和 |
AccountService |
将 与 一起使用 |
ActivityService |
使用 和 |
AlarmService |
将 与 一起使用 |
AppOpsService |
使用 和 |
AppSearchService |
使用 和 |
AppwidgetService |
将 与 一起使用 |
AudioService |
使用 和 |
BatteryService |
将 与 一起使用 |
BindAllowActivityStarts |
已过时.
标志 |
BindExternalServiceLong |
的工作方式与 相同 |
BindNotPerceptible |
已过时.
标志 |
BindSharedIsolatedProcess |
已过时.
的 |
BiometricService |
将 与 一起使用 |
BlobStoreService |
使用 和 |
BluetoothService |
使用 与 |
BugreportService |
用于捕获 bug 报告的服务。 (继承自 Context) |
CameraService |
使用 和 |
CaptioningService |
使用 与 |
CarrierConfigService |
将 与 一起使用 |
ClipboardService |
使用 和 |
CompanionDeviceService |
使用 与 |
ConnectivityDiagnosticsService |
使用 和 |
ConnectivityService |
使用 和 |
ConsumerIrService |
将 与 一起使用 |
CredentialService |
使用 和 |
CrossProfileAppsService |
使用 与 |
DeviceIdDefault |
默认设备 ID,即主 (非虚拟) 设备的 ID。 (继承自 Context) |
DeviceIdInvalid |
设备 ID 无效。 (继承自 Context) |
DeviceLockService |
将 与 一起使用 |
DevicePolicyService |
使用 和 |
DisplayHashService |
使用 和 |
DisplayService |
使用 和 |
DomainVerificationService |
使用 和 |
DownloadService |
使用 和 |
DropboxService |
使用 与 |
EuiccService |
使用 与 |
FileIntegrityService |
将 与 一起使用 |
FingerprintService |
使用 和 |
GameService |
将 与 一起使用 |
GrammaticalInflectionService |
将 与 一起使用 |
HardwarePropertiesService |
使用 和 |
HealthconnectService |
将 与 一起使用 |
InputMethodService |
使用 和 |
InputService |
使用 和 |
IpsecService |
使用 和 |
JobSchedulerService |
使用 和 |
KeyguardService |
将 与 一起使用 |
LauncherAppsService |
使用 和 |
LayoutInflaterService |
使用 和 |
LocaleService |
将 与 一起使用 |
LocationService |
使用 和 |
MediaCommunicationService |
将 与 一起使用 |
MediaMetricsService |
使用 和 |
MediaProjectionService |
使用 和 |
MediaRouterService |
使用 和 |
MediaSessionService |
使用 和 |
MidiService |
将 与 一起使用 |
NetworkStatsService |
将 与 一起使用 |
NfcService |
使用 与 |
NotificationService |
使用 和 |
NsdService |
将 与 一起使用 |
OverlayService |
使用 和 |
PeopleService |
使用 和 |
PerformanceHintService |
将 与 一起使用 |
PowerService |
使用 和 |
PrintService |
|
ReceiverExported |
已过时.
标志 |
ReceiverNotExported |
已过时.
标志 |
ReceiverVisibleToInstantApps |
已过时.
标志 |
RestrictionsService |
使用 和 |
RoleService |
使用 和 |
SearchService |
使用 和 |
SensorService |
将 与 一起使用 |
ShortcutService |
使用 和 |
StatusBarService |
使用 和 |
StorageService |
使用 和 |
StorageStatsService |
将 与 一起使用 |
SystemHealthService |
使用 和 |
TelecomService |
使用 和 |
TelephonyImsService |
将 与 一起使用 |
TelephonyService |
将 与 一起使用 |
TelephonySubscriptionService |
将 与 一起使用 |
TextClassificationService |
将 与 用于 |
TextServicesManagerService |
使用 和 |
TvInputService |
使用 和 |
TvInteractiveAppService |
使用 和 |
UiModeService |
将 与 一起使用 |
UsageStatsService |
将 与 一起使用 |
UsbService |
将 与 一起使用 |
UserService |
使用 和 |
VibratorManagerService |
使用 和 |
VibratorService |
使用 和 |
VirtualDeviceService |
使用 和 |
VpnManagementService |
使用 和 |
WallpaperService |
使用 与 |
WifiAwareService |
将 与 一起使用 |
WifiP2pService |
使用 和 |
WifiRttRangingService |
使用 和 |
WifiService |
使用 和 |
WindowService |
使用 和 |
属性
ApplicationContext |
返回当前进程的单个全局 Application 对象的上下文。 |
ApplicationInfo |
返回此上下文包的完整应用程序信息。 |
Assets |
返回应用程序包的 AssetManager 实例。 |
AttributionSource |
模拟 |
AttributionTag |
属性可用于复杂应用中,以逻辑方式分隔应用的各个部分。 (继承自 Context) |
CacheDir |
返回文件系统上特定于应用程序的缓存目录的绝对路径。 |
Class |
返回此 |
ClassLoader |
返回可用于检索此包中的类的类加载程序。 |
CodeCacheDir |
返回专用于存储缓存代码的文件系统上特定于应用程序的缓存目录的绝对路径。 |
ContentResolver |
返回应用程序包的 ContentResolver 实例。 |
DataDir |
模拟 |
DeviceId |
获取与此上下文关联的设备 ID。 (继承自 Context) |
Display |
获取与此上下文关联的显示。 (继承自 Context) |
ExternalCacheDir |
返回主外部文件系统 (上的目录的绝对路径,该目录位于应用程序可以放置其拥有的缓存文件的某个位置 ExternalStorageDirectory 。 |
FilesDir |
返回文件系统上存储使用 OpenFileOutput(String, FileCreationMode) 创建的文件的目录的绝对路径。 |
Handle |
基础 Android 实例的句柄。 (继承自 Object) |
IsDeviceProtectedStorage |
模拟 |
IsRestricted |
指示此上下文是否受到限制。 (继承自 Context) |
IsUiContext |
|
JniIdentityHashCode |
模拟 |
JniPeerMembers |
模拟 |
MainExecutor |
返回一个 |
MainLooper |
返回当前进程的main线程的 Looper。 |
NoBackupFilesDir |
返回文件系统上目录的绝对路径,类似于 FilesDir。 |
ObbDir |
如果可以找到任何) ,则返回此应用程序的 OBB 文件 (的主外部存储目录。 |
OpPackageName |
返回应该用于 |
PackageCodePath |
返回此上下文的主 Android 包的完整路径。 |
PackageManager |
返回 PackageManager 实例以查找全局包信息。 |
PackageName |
返回此应用程序的包的名称。 |
PackageResourcePath |
返回此上下文的主 Android 包的完整路径。 |
Params |
返回创建此上下文时使用 的参数集(如果它是通过 |
PeerReference |
模拟 |
Resources |
返回应用程序包的 Resources 实例。 |
Theme |
返回与此上下文关联的 Theme 对象。 |
ThresholdClass |
此 API 支持 Mono for Android 基础结构,不应直接从代码使用。 |
ThresholdType |
此 API 支持 Mono for Android 基础结构,不应直接从代码使用。 |
Wallpaper | |
WallpaperDesiredMinimumHeight | |
WallpaperDesiredMinimumWidth |
方法
显式接口实现
IJavaPeerable.Disposed() |
模拟 |
IJavaPeerable.DisposeUnlessReferenced() |
模拟 |
IJavaPeerable.Finalized() |
模拟 |
IJavaPeerable.JniManagedPeerState |
模拟 |
IJavaPeerable.SetJniIdentityHashCode(Int32) |
模拟 |
IJavaPeerable.SetJniManagedPeerState(JniManagedPeerStates) |
模拟 |
IJavaPeerable.SetPeerReference(JniObjectReference) |
模拟 |
扩展方法
JavaCast<TResult>(IJavaObject) |
执行 Android 运行时检查的类型转换。 |
JavaCast<TResult>(IJavaObject) |
模拟 |
GetJniTypeName(IJavaPeerable) |
模拟 |