Struct droid_wrap::android::content::ContextWrapper

source ·
pub struct ContextWrapper { /* private fields */ }
Expand description
  • Context 的代理实现,它只是将其所有调用委托给另一个 Context。可以创建子类来修改行为,而无需更改原始 Context。

Implementations§

source§

impl ContextWrapper

source

pub fn get_class_loader(&self) -> ClassLoader

返回可用于查询此包中的类的类加载器。

source

pub fn send_broadcast(&self, intent: &Intent)

将给定的意图广播给所有感兴趣的 BroadcastReceiver。此调用是异步的;它会立即返回,您将在接收器运行时继续执行。接收器不会传播任何结果,接收器也无法中止广播。如果您想允许接收器传播结果或中止广播,则必须使用 sendOrderedBroadcast(Intent, String) 发送有序广播。有关 Intent 广播的更多信息,请参阅 BroadcastReceiver。 intent 要广播的 Intent;与此 Intent 匹配的所有接收器都将收到广播。

Methods from Deref<Target = Context>§

source

pub const POWER_SERVICE: &'static str = "power"

source

pub const POWER_STATS_SERVICE: &'static str = "powerstats"

source

pub const RECOVERY_SERVICE: &'static str = "recovery"

source

pub const SYSTEM_UPDATE_SERVICE: &'static str = "system_update"

source

pub const WINDOW_SERVICE: &'static str = "window"

source

pub const LAYOUT_INFLATER_SERVICE: &'static str = "layout_inflater"

source

pub const ACCOUNT_SERVICE: &'static str = "account"

source

pub const ACTIVITY_SERVICE: &'static str = "activity"

source

pub const ACTIVITY_TASK_SERVICE: &'static str = "activity_task"

source

pub const URI_GRANTS_SERVICE: &'static str = "uri_grants"

source

pub const ALARM_SERVICE: &'static str = "alarm"

source

pub const NOTIFICATION_SERVICE: &'static str = "notification"

source

pub const ACCESSIBILITY_SERVICE: &'static str = "accessibility"

source

pub const CAPTIONING_SERVICE: &'static str = "captioning"

source

pub const KEYGUARD_SERVICE: &'static str = "keyguard"

source

pub const LOCATION_SERVICE: &'static str = "location"

source

pub const COUNTRY_DETECTOR: &'static str = "country_detector"

source

pub const SEARCH_SERVICE: &'static str = "search"

source

pub const SENSOR_SERVICE: &'static str = "sensor"

source

pub const SENSOR_PRIVACY_SERVICE: &'static str = "sensor_privacy"

source

pub const STORAGE_SERVICE: &'static str = "storage"

source

pub const STORAGE_STATS_SERVICE: &'static str = "storagestats"

source

pub const WALLPAPER_SERVICE: &'static str = "wallpaper"

source

pub const VIBRATOR_MANAGER_SERVICE: &'static str = "vibrator_manager"

source

pub const VIBRATOR_SERVICE: &'static str = "vibrator"

source

pub const STATUS_BAR_SERVICE: &'static str = "statusbar"

source

pub const CONNECTIVITY_SERVICE: &'static str = "connectivity"

source

pub const PAC_PROXY_SERVICE: &'static str = "pac_proxy"

source

pub const VCN_MANAGEMENT_SERVICE: &'static str = "vcn_management"

source

pub const NETD_SERVICE: &'static str = "netd"

source

pub const NETWORK_STACK_SERVICE: &'static str = "network_stack"

source

pub const TETHERING_SERVICE: &'static str = "tethering"

source

pub const IPSEC_SERVICE: &'static str = "ipsec"

source

pub const VPN_MANAGEMENT_SERVICE: &'static str = "vpn_management"

source

pub const CONNECTIVITY_DIAGNOSTICS_SERVICE: &'static str = "connectivity_diagnostics"

source

pub const TEST_NETWORK_SERVICE: &'static str = "test_network"

source

pub const UPDATE_LOCK_SERVICE: &'static str = "updatelock"

source

pub const NETWORKMANAGEMENT_SERVICE: &'static str = "network_management"

source

pub const SLICE_SERVICE: &'static str = "slice"

source

pub const NETWORK_STATS_SERVICE: &'static str = "netstats"

source

pub const WIFI_SERVICE: &'static str = "wifi"

source

pub const WIFI_NL80211_SERVICE: &'static str = "wifinl80211"

source

pub const WIFI_P2P_SERVICE: &'static str = "wifip2p"

source

pub const WIFI_AWARE_SERVICE: &'static str = "wifiaware"

source

pub const WIFI_SCANNING_SERVICE: &'static str = "wifiscanner"

source

pub const WIFI_RTT_SERVICE: &'static str = "rttmanager"

source

pub const WIFI_RTT_RANGING_SERVICE: &'static str = "wifirtt"

source

pub const LOWPAN_SERVICE: &'static str = "lowpan"

source

pub const ETHERNET_SERVICE: &'static str = "ethernet"

source

pub const NSD_SERVICE: &'static str = "servicediscovery"

source

pub const AUDIO_SERVICE: &'static str = "audio"

source

pub const AUDIO_DEVICE_VOLUME_SERVICE: &'static str = "audio_device_volume"

source

pub const MEDIA_TRANSCODING_SERVICE: &'static str = "media_transcoding"

source

pub const AUTH_SERVICE: &'static str = "auth"

source

pub const FINGERPRINT_SERVICE: &'static str = "fingerprint"

source

pub const FACE_SERVICE: &'static str = "face"

source

pub const IRIS_SERVICE: &'static str = "iris"

source

pub const BIOMETRIC_SERVICE: &'static str = "biometric"

source

pub const MEDIA_COMMUNICATION_SERVICE: &'static str = "media_communication"

source

pub const MEDIA_ROUTER_SERVICE: &'static str = "media_router"

source

pub const MEDIA_SESSION_SERVICE: &'static str = "media_session"

source

pub const TELEPHONY_SERVICE: &'static str = "phone"

source

pub const TELEPHONY_SUBSCRIPTION_SERVICE: &'static str = "telephony_subscription_service"

source

pub const TELECOM_SERVICE: &'static str = "telecom"

source

pub const CARRIER_CONFIG_SERVICE: &'static str = "carrier_config"

source

pub const EUICC_SERVICE: &'static str = "euicc"

source

pub const EUICC_CARD_SERVICE: &'static str = "euicc_card"

source

pub const MMS_SERVICE: &'static str = "mms"

source

pub const CLIPBOARD_SERVICE: &'static str = "clipboard"

source

pub const TEXT_CLASSIFICATION_SERVICE: &'static str = "textclassification"

source

pub const SELECTION_TOOLBAR_SERVICE: &'static str = "selection_toolbar"

source

pub const FONT_SERVICE: &'static str = "font"

source

pub const ATTENTION_SERVICE: &'static str = "attention"

source

pub const ROTATION_RESOLVER_SERVICE: &'static str = "resolver"

source

pub const INPUT_METHOD_SERVICE: &'static str = "input_method"

source

pub const TEXT_SERVICES_MANAGER_SERVICE: &'static str = "textservices"

source

pub const APPWIDGET_SERVICE: &'static str = "appwidget"

source

pub const VOICE_INTERACTION_MANAGER_SERVICE: &'static str = "voiceinteraction"

source

pub const AUTOFILL_MANAGER_SERVICE: &'static str = "autofill"

source

pub const TEXT_TO_SPEECH_MANAGER_SERVICE: &'static str = "texttospeech"

source

pub const CONTENT_CAPTURE_MANAGER_SERVICE: &'static str = "content_capture"

source

pub const TRANSLATION_MANAGER_SERVICE: &'static str = "translation"

source

pub const UI_TRANSLATION_SERVICE: &'static str = "ui_translation"

source

pub const CONTENT_SUGGESTIONS_SERVICE: &'static str = "content_suggestions"

source

pub const APP_PREDICTION_SERVICE: &'static str = "app_prediction"

source

pub const SEARCH_UI_SERVICE: &'static str = "search_ui"

source

pub const SMARTSPACE_SERVICE: &'static str = "smartspace"

source

pub const CLOUDSEARCH_SERVICE: &'static str = "cloudsearch"

source

pub const SOUND_TRIGGER_SERVICE: &'static str = "soundtrigger"

source

pub const SOUND_TRIGGER_MIDDLEWARE_SERVICE: &'static str = "soundtrigger_middleware"

source

pub const WALLPAPER_EFFECTS_GENERATION_SERVICE: &'static str = "wallpaper_effects_generation"

source

pub const MUSIC_RECOGNITION_SERVICE: &'static str = "music_recognition"

source

pub const PERMISSION_SERVICE: &'static str = "permission"

source

pub const LEGACY_PERMISSION_SERVICE: &'static str = "legacy_permission"

source

pub const PERMISSION_CONTROLLER_SERVICE: &'static str = "permission_controller"

source

pub const PERMISSION_CHECKER_SERVICE: &'static str = "permission_checker"

source

pub const PERMISSION_ENFORCER_SERVICE: &'static str = "permission_enforcer"

source

pub const APP_HIBERNATION_SERVICE: &'static str = "app_hibernation"

source

pub const BACKUP_SERVICE: &'static str = "backup"

source

pub const ROLLBACK_SERVICE: &'static str = "rollback"

source

pub const REBOOT_READINESS_SERVICE: &'static str = "reboot_readiness"

source

pub const DROPBOX_SERVICE: &'static str = "dropbox"

source

pub const BACKGROUND_INSTALL_CONTROL_SERVICE: &'static str = "background_install_control"

source

pub const BINARY_TRANSPARENCY_SERVICE: &'static str = "transparency"

source

pub const DEVICE_IDLE_CONTROLLER: &'static str = "deviceidle"

source

pub const POWER_WHITELIST_MANAGER: &'static str = "power_whitelist"

source

pub const POWER_EXEMPTION_SERVICE: &'static str = "power_exemption"

source

pub const DEVICE_POLICY_SERVICE: &'static str = "device_policy"

source

pub const UI_MODE_SERVICE: &'static str = "uimode"

source

pub const DOWNLOAD_SERVICE: &'static str = "download"

source

pub const BATTERY_SERVICE: &'static str = "batterymanager"

source

pub const NFC_SERVICE: &'static str = "nfc"

source

pub const BLUETOOTH_SERVICE: &'static str = "bluetooth"

source

pub const SIP_SERVICE: &'static str = "sip"

source

pub const USB_SERVICE: &'static str = "usb"

source

pub const ADB_SERVICE: &'static str = "adb"

source

pub const SERIAL_SERVICE: &'static str = "serial"

source

pub const HDMI_CONTROL_SERVICE: &'static str = "hdmi_control"

source

pub const INPUT_SERVICE: &'static str = "input"

source

pub const DISPLAY_SERVICE: &'static str = "display"

source

pub const COLOR_DISPLAY_SERVICE: &'static str = "color_display"

source

pub const USER_SERVICE: &'static str = "user"

source

pub const LAUNCHER_APPS_SERVICE: &'static str = "launcherapps"

source

pub const RESTRICTIONS_SERVICE: &'static str = "restrictions"

source

pub const APP_OPS_SERVICE: &'static str = "appops"

source

pub const ROLE_SERVICE: &'static str = "role"

source

pub const CAMERA_SERVICE: &'static str = "camera"

source

pub const PRINT_SERVICE: &'static str = "print"

source

pub const COMPANION_DEVICE_SERVICE: &'static str = "companiondevice"

source

pub const VIRTUAL_DEVICE_SERVICE: &'static str = "virtualdevice"

source

pub const CONSUMER_IR_SERVICE: &'static str = "consumer_ir"

source

pub const TRUST_SERVICE: &'static str = "trust"

source

pub const TV_INTERACTIVE_APP_SERVICE: &'static str = "tv_interactive_app"

source

pub const TV_INPUT_SERVICE: &'static str = "tv_input"

source

pub const TV_TUNER_RESOURCE_MGR_SERVICE: &'static str = "tv_tuner_resource_mgr"

source

pub const NETWORK_SCORE_SERVICE: &'static str = "network_score"

source

pub const USAGE_STATS_SERVICE: &'static str = "usagestats"

source

pub const JOB_SCHEDULER_SERVICE: &'static str = "jobscheduler"

source

pub const RESOURCE_ECONOMY_SERVICE: &'static str = "tare"

source

pub const PERSISTENT_DATA_BLOCK_SERVICE: &'static str = "persistent_data_block"

source

pub const OEM_LOCK_SERVICE: &'static str = "oem_lock"

source

pub const MEDIA_PROJECTION_SERVICE: &'static str = "media_projection"

source

pub const MIDI_SERVICE: &'static str = "midi"

source

pub const RADIO_SERVICE: &'static str = "broadcastradio"

source

pub const HARDWARE_PROPERTIES_SERVICE: &'static str = "hardware_properties"

source

pub const THERMAL_SERVICE: &'static str = "thermalservice"

source

pub const PERFORMANCE_HINT_SERVICE: &'static str = "performance_hint"

source

pub const SHORTCUT_SERVICE: &'static str = "shortcut"

source

pub const CONTEXTHUB_SERVICE: &'static str = "contexthub"

source

pub const SYSTEM_HEALTH_SERVICE: &'static str = "systemhealth"

source

pub const GATEKEEPER_SERVICE: &'static str = "android.service.gatekeeper.IGateKeeperService"

source

pub const DEVICE_IDENTIFIERS_SERVICE: &'static str = "device_identifiers"

source

pub const INCIDENT_SERVICE: &'static str = "incident"

source

pub const INCIDENT_COMPANION_SERVICE: &'static str = "incidentcompanion"

source

pub const STATS_MANAGER_SERVICE: &'static str = "statsmanager"

source

pub const STATS_COMPANION_SERVICE: &'static str = "statscompanion"

source

pub const STATS_BOOTSTRAP_ATOM_SERVICE: &'static str = "statsbootstrap"

source

pub const STATS_MANAGER: &'static str = "stats"

source

pub const PLATFORM_COMPAT_SERVICE: &'static str = "platform_compat"

source

pub const PLATFORM_COMPAT_NATIVE_SERVICE: &'static str = "platform_compat_native"

source

pub const BUGREPORT_SERVICE: &'static str = "bugreport"

source

pub const OVERLAY_SERVICE: &'static str = "overlay"

source

pub const RESOURCES_SERVICE: &'static str = "resources"

source

pub const IDMAP_SERVICE: &'static str = "idmap"

source

pub const VR_SERVICE: &'static str = "vrmanager"

source

pub const CROSS_PROFILE_APPS_SERVICE: &'static str = "crossprofileapps"

source

pub const SECURE_ELEMENT_SERVICE: &'static str = "secure_element"

source

pub const TIME_DETECTOR_SERVICE: &'static str = "time_detector"

source

pub const TIME_ZONE_DETECTOR_SERVICE: &'static str = "time_zone_detector"

source

pub const TIME_MANAGER_SERVICE: &'static str = "time_manager"

source

pub const APP_BINDING_SERVICE: &'static str = "app_binding"

source

pub const TELEPHONY_IMS_SERVICE: &'static str = "telephony_ims"

source

pub const SYSTEM_CONFIG_SERVICE: &'static str = "system_config"

source

pub const TELEPHONY_RCS_MESSAGE_SERVICE: &'static str = "ircsmessage"

source

pub const DYNAMIC_SYSTEM_SERVICE: &'static str = "dynamic_system"

source

pub const BLOB_STORE_SERVICE: &'static str = "blob_store"

source

pub const TELEPHONY_REGISTRY_SERVICE: &'static str = "telephony_registry"

source

pub const BATTERY_STATS_SERVICE: &'static str = "batterystats"

source

pub const APP_SEARCH_SERVICE: &'static str = "app_search"

source

pub const APP_INTEGRITY_SERVICE: &'static str = "app_integrity"

source

pub const DATA_LOADER_MANAGER_SERVICE: &'static str = "dataloader_manager"

source

pub const INCREMENTAL_SERVICE: &'static str = "incremental"

source

pub const ATTESTATION_VERIFICATION_SERVICE: &'static str = "attestation_verification"

source

pub const FILE_INTEGRITY_SERVICE: &'static str = "file_integrity"

source

pub const REMOTE_PROVISIONING_SERVICE: &'static str = "remote_provisioning"

source

pub const LIGHTS_SERVICE: &'static str = "lights"

source

pub const UWB_SERVICE: &'static str = "uwb"

source

pub const DREAM_SERVICE: &'static str = "dream"

source

pub const SMS_SERVICE: &'static str = "sms"

source

pub const PEOPLE_SERVICE: &'static str = "people"

source

pub const DEVICE_STATE_SERVICE: &'static str = "device_state"

source

pub const MEDIA_METRICS_SERVICE: &'static str = "media_metrics"

source

pub const SPEECH_RECOGNITION_SERVICE: &'static str = "speech_recognition"

source

pub const GAME_SERVICE: &'static str = "game"

source

pub const DOMAIN_VERIFICATION_SERVICE: &'static str = "domain_verification"

source

pub const DISPLAY_HASH_SERVICE: &'static str = "display_hash"

source

pub const LOCALE_SERVICE: &'static str = "locale"

source

pub const SAFETY_CENTER_SERVICE: &'static str = "safety_center"

source

pub const NEARBY_SERVICE: &'static str = "nearby"

source

pub const AMBIENT_CONTEXT_SERVICE: &'static str = "ambient_context"

source

pub const WEARABLE_SENSING_SERVICE: &'static str = "wearable_sensing"

source

pub const HEALTHCONNECT_SERVICE: &'static str = "healthconnect"

source

pub const CREDENTIAL_SERVICE: &'static str = "credential"

source

pub const DEVICE_LOCK_SERVICE: &'static str = "device_lock"

source

pub const VIRTUALIZATION_SERVICE: &'static str = "virtualization"

source

pub const GRAMMATICAL_INFLECTION_SERVICE: &'static str = "grammatical_inflection"

source

pub const SATELLITE_SERVICE: &'static str = "satellite"

source

pub const SHARED_CONNECTIVITY_SERVICE: &'static str = "shared_connectivity"

source

pub fn get_class_loader(&self) -> ClassLoader

  • 返回可用于查询此包中的类的类加载器。
source

pub fn send_broadcast(&self, intent: &Intent)

  • 将给定的意图广播给所有感兴趣的 BroadcastReceiver。此调用是异步的;它会立即返回,您将在接收器运行时继续执行。接收器不会传播任何结果,接收器也无法中止广播。如果您想允许接收器传播结果或中止广播,则必须使用 sendOrderedBroadcast(Intent, String) 发送有序广播。有关 Intent 广播的更多信息,请参阅 BroadcastReceiver。
  • intent 要广播的 Intent;与此 Intent 匹配的所有接收器都将收到广播。
source

pub fn start_activity(&self, intent: &Intent)

  • 与 startActivity(Intent, Bundle) 相同,但未指定任何选项。
  • intent 要启动的活动的描述。
  • 抛出:ActivityNotFoundException – `
source

pub fn get_package_name(&self) -> String

  • 返回此应用程序包的名称。
source

pub fn get_base_package_name(&self) -> String

  • 返回此上下文所派生自的基础上下文的名称。这与 getOpPackageName() 相同,除非系统组件加载到其他应用进程中,在这种情况下 getOpPackageName() 将是该进程中主软件包的名称(以便应用操作 uid 验证可以使用该名称)。
source

pub fn get_op_package_name(&self) -> String

  • 返回应用于此上下文中的 android.app.AppOpsManager 调用的包名称,以便 app ops manager 的 uid 验证可以使用该名称。这通常不适用于第三方应用程序开发人员。
source

pub fn get_attribution_tag(&self) -> Option<String>

  • 归因可用于复杂的应用中,以在逻辑上区分应用的各个部分。例如,博客应用可能还内置有即时通讯应用。在这种情况下,每个子功能可以使用两个单独的标签。
  • 返回:此上下文所针对的归因标签,如果这是默认标签,则返回 null。
source

pub fn get_package_resource_path(&self) -> String

  • 返回此上下文的主要 Android 包的完整路径。Android 包是一个 ZIP 文件,其中包含应用程序的主要资源。注意:这通常对应用程序没有用,因为它们不应直接访问文件系统。
  • 返回:String 资源路径。
source

pub fn get_package_code_path(&self) -> String

  • 返回此上下文的主要 Android 包的完整路径。Android 包是一个 ZIP 文件,其中包含应用程序的主要代码和资产。
  • 注意:这通常对应用程序没有用,因为它们不应直接访问文件系统。
  • 返回:String 代码和资产的路径。
source

pub fn get_system_service(&self, name: String) -> Option<Object>

  • 按名称返回系统级服务的句柄。返回对象的类因请求的名称而异。当前可用的名称为:
  • WINDOW_SERVICE (“window”)
  • 您可以在顶级窗口管理器中放置自定义窗口。返回的对象是 WindowManager。只能从可视上下文(例如 Activity 或使用 createWindowContext(int, Bundle) 创建的上下文)中获取,这些上下文会根据屏幕区域的配置和可视边界进行调整。
  • LAYOUT_INFLATER_SERVICE (“layout_inflater”)
  • android.view.LayoutInflater 用于在此上下文中填充布局资源。只能从可视上下文(例如 Activity 或使用 createWindowContext(int, Bundle) 创建的上下文)获取,这些上下文会根据屏幕区域的配置和可视边界进行调整。
  • ACTIVITY_SERVICE (“activity”)
  • 用于与系统全局活动状态交互的 ActivityManager。
  • WALLPAPER_SERVICE (“wallpaper”)
  • android.service.wallpaper.WallpaperService 用于在此上下文中访问壁纸。只能从可视上下文(例如 Activity 或使用 createWindowContext(int, Bundle) 创建的上下文)获取,这些上下文会根据屏幕区域的配置和可视边界进行调整。
  • POWER_SERVICE (“power”)
  • 一个用于控制电源管理的android.os.PowerManager。
  • ALARM_SERVICE (“alarm”)
  • 一个 Android 应用程序 AlarmManager,用于在您选择的时间接收意图。
  • NOTIFICATION_SERVICE (“notification”)
  • android.app.NotificationManager,用于通知用户后台事件。
  • KEYGUARD_SERVICE (“keyguard”)
  • 一个用于控制键盘锁的 android.app.KeyguardManager。
  • LOCATION_SERVICE (“location”)
  • android.location.LocationManager 用于控制位置(例如 GPS)更新。
  • SEARCH_SERVICE (“search”)
  • 一个用于处理搜索的android.app.SearchManager。
  • VIBRATOR_MANAGER_SERVICE (“vibrator_manager”)
  • android.os.VibratorManager,用于访问设备振动器、与各个振动器交互以及在多个振动器上播放同步效果。
  • VIBRATOR_SERVICE (“vibrator”)
  • 一个android.os.Vibrator,用于与振动器硬件进行交互。
  • CONNECTIVITY_SERVICE (“connectivity”)
  • 用于处理网络连接管理的 ConnectivityManager。
  • IPSEC_SERVICE (“ipsec”)
  • IpSecManager 用于管理套接字和网络上的 IPSec。
  • WIFI_SERVICE (“wifi”)
  • 用于管理 Wi-Fi 连接的 WifiManager。在 Android 7 之前的版本中,应仅从应用上下文中获取它,而不能从任何其他派生上下文中获取它,以避免调用过程中出现内存泄漏。
  • WIFI_AWARE_SERVICE (“wifiaware”)
  • WifiAwareManager 用于管理 Wi-Fi Aware 发现和连接。
  • WIFI_P2P_SERVICE (“wifip2p”)
  • WifiP2pManager 用于管理 Wi-Fi Direct 连接。
  • INPUT_METHOD_SERVICE (“input_method”)
  • 用于管理输入方法的 InputMethodManager。
  • UI_MODE_SERVICE (“uimode”)
  • 一个用于控制 UI 模式的 android.app.UiModeManager。
  • DOWNLOAD_SERVICE (“download”)
  • 用于请求 HTTP 下载的 android.app.DownloadManager
  • BATTERY_SERVICE (“batterymanager”)
  • 用于管理电池状态的 android.os.BatteryManager
  • JOB_SCHEDULER_SERVICE (“taskmanager”)
  • 一个用于管理计划任务的android.app.job.JobScheduler
  • NETWORK_STATS_SERVICE (“netstats”)
  • 用于查询网络使用情况统计数据的 NetworkStatsManager。
  • HARDWARE_PROPERTIES_SERVICE (“hardware_properties”)
  • 用于访问硬件属性的 android.os.HardwarePropertiesManager。
  • DOMAIN_VERIFICATION_SERVICE (“domain_verification”)
  • android.content.pm.verify.domain.DomainVerificationManager,用于访问 Web 域批准状态。
  • DISPLAY_HASH_SERVICE (“display_hash”)
  • android.view.displayhash.DisplayHashManager 用于管理显示哈希。
  • 注意:通过此 API 获取的系统服务可能与获取它们的上下文密切相关。一般来说,不要在各种不同的上下文(活动、应用程序、服务、提供商等)之间共享服务对象。
  • 注意:PackageManager.isInstantApp() 返回 true 的免安装应用无法访问以下系统服务:DEVICE_POLICY_SERVICE、FINGERPRINT_SERVICE、KEYGUARD_SERVICE、SHORTCUT_SERVICE、USB_SERVICE、WALLPAPER_SERVICE、WIFI_P2P_SERVICE、WIFI_SERVICE、WIFI_AWARE_SERVICE。对于这些服务,此方法将返回 null。通常,如果您以免安装应用的形式运行,则应始终检查此方法的结果是否为 null。
  • 注意:在实现此方法时,请记住可以在较新的 Android 版本中添加新服务,因此如果您只是在寻找上面提到的明确名称,请确保在您无法识别该名称时返回 null — 如果您抛出 RuntimeException 异常,您的应用可能会在新的 Android 版本上中断。
  • 返回:如果名称不存在则返回 null。
  • name 所需服务的名称。

Methods from Deref<Target = GlobalRef>§

source

pub fn as_obj(&self) -> &JObject<'static>

Get the object from the global ref

This borrows the ref and prevents it from being dropped as long as the JObject sticks around.

Methods from Deref<Target = JObject<'static>>§

source

pub fn as_raw(&self) -> *mut _jobject

Returns the raw JNI pointer.

Trait Implementations§

source§

impl Debug for ContextWrapper

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl Deref for ContextWrapper

§

type Target = Context

The resulting type after dereferencing.
source§

fn deref(&self) -> &Self::Target

Dereferences the value.
source§

impl From<&GlobalRef> for ContextWrapper

source§

fn from(obj: &GlobalRef) -> Self

Converts to this type from the input type.
source§

impl Into<GlobalRef> for &ContextWrapper

source§

fn into(self) -> GlobalRef

Converts this type into the (usually inferred) input type.
source§

impl JObjNew for ContextWrapper

§

type Fields = ()

字段类型
source§

fn _new(this: &GlobalRef, fields: Self::Fields) -> Self

从java对象创建本地对象。 this java对象引用。
source§

fn null() -> Self
where Self: Sized, Self::Fields: Default,

创建空对象。
source§

impl JObjRef for ContextWrapper

source§

fn java_ref(&self) -> GlobalRef

获取java对象引用。
source§

impl JType for ContextWrapper

§

type Error = Error

错误类型。
source§

const CLASS: &'static str = "android/content/ContextWrapper"

java类的名称。
source§

const OBJECT_SIG: &'static str = "Landroid/content/ContextWrapper;"

对象的签名描述。
source§

impl PartialEq for ContextWrapper

source§

fn eq(&self, other: &Self) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl ToString for ContextWrapper

source§

fn to_string(&self) -> String

Converts the given value to a String. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.