Compartilhar via


DevicePolicyManager.TransferOwnership Method

Definition

Changes the current administrator to another one.

[Android.Runtime.Register("transferOwnership", "(Landroid/content/ComponentName;Landroid/content/ComponentName;Landroid/os/PersistableBundle;)V", "GetTransferOwnership_Landroid_content_ComponentName_Landroid_content_ComponentName_Landroid_os_PersistableBundle_Handler", ApiSince=28)]
public virtual void TransferOwnership (Android.Content.ComponentName admin, Android.Content.ComponentName target, Android.OS.PersistableBundle? bundle);
[<Android.Runtime.Register("transferOwnership", "(Landroid/content/ComponentName;Landroid/content/ComponentName;Landroid/os/PersistableBundle;)V", "GetTransferOwnership_Landroid_content_ComponentName_Landroid_content_ComponentName_Landroid_os_PersistableBundle_Handler", ApiSince=28)>]
abstract member TransferOwnership : Android.Content.ComponentName * Android.Content.ComponentName * Android.OS.PersistableBundle -> unit
override this.TransferOwnership : Android.Content.ComponentName * Android.Content.ComponentName * Android.OS.PersistableBundle -> unit

Parameters

admin
ComponentName

which DeviceAdminReceiver this request is associated with.

target
ComponentName

which DeviceAdminReceiver we want the new administrator to be.

bundle
PersistableBundle

data to be sent to the new administrator.

Attributes

Remarks

Changes the current administrator to another one. All policies from the current administrator are migrated to the new administrator. The whole operation is atomic - the transfer is either complete or not done at all.

Depending on the current administrator (device owner, profile owner), you have the following expected behaviour: <ul> <li>A device owner can only be transferred to a new device owner</li> <li>A profile owner can only be transferred to a new profile owner</li> </ul>

Use the bundle parameter to pass data to the new administrator. The data will be received in the DeviceAdminReceiver#onTransferOwnershipComplete(Context, PersistableBundle) callback of the new administrator.

The transfer has failed if the original administrator is still the corresponding owner after calling this method.

The incoming target administrator must have the &lt;support-transfer-ownership /&gt; tag inside the &lt;device-admin&gt;&lt;/device-admin&gt; tags in the xml file referenced by DeviceAdminReceiver#DEVICE_ADMIN_META_DATA. Otherwise an IllegalArgumentException will be thrown.

Java documentation for android.app.admin.DevicePolicyManager.transferOwnership(android.content.ComponentName, android.content.ComponentName, android.os.PersistableBundle).

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