Udostępnij za pośrednictwem


DevicePolicyManager.BindDeviceAdminServiceAsUser Method

Definition

Overloads

BindDeviceAdminServiceAsUser(ComponentName, Intent, IServiceConnection, Bind, UserHandle)

Called by a device owner to bind to a service from a secondary managed user or vice versa.

BindDeviceAdminServiceAsUser(ComponentName, Intent, IServiceConnection, Context+BindServiceFlags, UserHandle)

BindDeviceAdminServiceAsUser(ComponentName, Intent, IServiceConnection, Bind, UserHandle)

Called by a device owner to bind to a service from a secondary managed user or vice versa.

[Android.Runtime.Register("bindDeviceAdminServiceAsUser", "(Landroid/content/ComponentName;Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/UserHandle;)Z", "GetBindDeviceAdminServiceAsUser_Landroid_content_ComponentName_Landroid_content_Intent_Landroid_content_ServiceConnection_ILandroid_os_UserHandle_Handler", ApiSince=26)]
public virtual bool BindDeviceAdminServiceAsUser (Android.Content.ComponentName admin, Android.Content.Intent serviceIntent, Android.Content.IServiceConnection conn, Android.Content.Bind flags, Android.OS.UserHandle targetUser);
[<Android.Runtime.Register("bindDeviceAdminServiceAsUser", "(Landroid/content/ComponentName;Landroid/content/Intent;Landroid/content/ServiceConnection;ILandroid/os/UserHandle;)Z", "GetBindDeviceAdminServiceAsUser_Landroid_content_ComponentName_Landroid_content_Intent_Landroid_content_ServiceConnection_ILandroid_os_UserHandle_Handler", ApiSince=26)>]
abstract member BindDeviceAdminServiceAsUser : Android.Content.ComponentName * Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Bind * Android.OS.UserHandle -> bool
override this.BindDeviceAdminServiceAsUser : Android.Content.ComponentName * Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Bind * Android.OS.UserHandle -> bool

Parameters

admin
ComponentName

Which DeviceAdminReceiver this request is associated with.

serviceIntent
Intent

Identifies the service to connect to. The Intent must specify either an explicit component name or a package name to match an IntentFilter published by a service.

conn
IServiceConnection

Receives information as the service is started and stopped in main thread. This must be a valid ServiceConnection object; it must not be null.

flags
Bind

Operation options for the binding operation. See Context#bindService(Intent, ServiceConnection, int).

targetUser
UserHandle

Which user to bind to. Must be one of the users returned by #getBindDeviceAdminTargetUsers, otherwise a SecurityException will be thrown.

Returns

If you have successfully bound to the service, true is returned; false is returned if the connection is not made and you will not receive the service object.

Attributes

Remarks

Called by a device owner to bind to a service from a secondary managed user or vice versa. See #getBindDeviceAdminTargetUsers for the pre-requirements of a device owner to bind to services of another managed user.

The service must be protected by android.Manifest.permission#BIND_DEVICE_ADMIN. Note that the Context used to obtain this DevicePolicyManager instance via Context#getSystemService(Class) will be used to bind to the android.app.Service.

Note: This method used to be available for communication between device owner and profile owner. However, since Android 11, this combination is not possible. This method is now only useful for communication between device owner and managed secondary users.

Java documentation for android.app.admin.DevicePolicyManager.bindDeviceAdminServiceAsUser(android.content.ComponentName, android.content.Intent, android.content.ServiceConnection, int, android.os.UserHandle).

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

BindDeviceAdminServiceAsUser(ComponentName, Intent, IServiceConnection, Context+BindServiceFlags, UserHandle)

[Android.Runtime.Register("bindDeviceAdminServiceAsUser", "(Landroid/content/ComponentName;Landroid/content/Intent;Landroid/content/ServiceConnection;Landroid/content/Context$BindServiceFlags;Landroid/os/UserHandle;)Z", "GetBindDeviceAdminServiceAsUser_Landroid_content_ComponentName_Landroid_content_Intent_Landroid_content_ServiceConnection_Landroid_content_Context_BindServiceFlags_Landroid_os_UserHandle_Handler", ApiSince=34)]
public virtual bool BindDeviceAdminServiceAsUser (Android.Content.ComponentName admin, Android.Content.Intent serviceIntent, Android.Content.IServiceConnection conn, Android.Content.Context.BindServiceFlags flags, Android.OS.UserHandle targetUser);
[<Android.Runtime.Register("bindDeviceAdminServiceAsUser", "(Landroid/content/ComponentName;Landroid/content/Intent;Landroid/content/ServiceConnection;Landroid/content/Context$BindServiceFlags;Landroid/os/UserHandle;)Z", "GetBindDeviceAdminServiceAsUser_Landroid_content_ComponentName_Landroid_content_Intent_Landroid_content_ServiceConnection_Landroid_content_Context_BindServiceFlags_Landroid_os_UserHandle_Handler", ApiSince=34)>]
abstract member BindDeviceAdminServiceAsUser : Android.Content.ComponentName * Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Context.BindServiceFlags * Android.OS.UserHandle -> bool
override this.BindDeviceAdminServiceAsUser : Android.Content.ComponentName * Android.Content.Intent * Android.Content.IServiceConnection * Android.Content.Context.BindServiceFlags * Android.OS.UserHandle -> bool

Parameters

serviceIntent
Intent
targetUser
UserHandle

Returns

Attributes

Applies to