Start Device Manager, windows Start Manager
/*** Activate the Device Manager ** @ param context * Context object */public static void activeApp (context) {if (context instanceof Activity) {activeApplication (context );} else {Intent in = new Intent (context, StartDeviceManagerActivity. class); in. addFlags (Intent. FLAG_ACTIVITY_NEW_TASK); context. startActivity (in );}}
/*** Activate the Device Manager ** @ param context * Context object */private static void activeApplication (context) {DevicePolicyManager dpm = (DevicePolicyManager) context. getSystemService (Context. DEVICE_POLICY_SERVICE); ComponentName cm = new ComponentName (context, MyDeviceAdminReceiver. class); if (! Dpm. isAdminActive (cm) {Intent in = new Intent (DevicePolicyManager. ACTION_ADD_DEVICE_ADMIN); in. putExtra (DevicePolicyManager. EXTRA_DEVICE_ADMIN, cm); in. putExtra (DevicePolicyManager. EXTRA_ADD_EXPLANATION, context. getPackageName (); context. startActivity (in );}}
StartDeviceManagerActivity:
package com.home.util;import android.app.Activity;import android.os.Bundle;public class StartDeviceManagerActivity extends Activity {@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);ApplicationUtil.activeApp(this);finish();}}
Configuration:
<! -- Activate the expected broadcast --> <receiver er android: name = "com. home. util. myDeviceAdminReceiver "android: permission =" android. permission. BIND_DEVICE_ADMIN "> <meta-data android: name =" android. app. device_admin "android: resource =" @ xml/device_admin "/> <intent-filter> <action android: name =" android. app. action. DEVICE_ADMIN_ENABLED "/> </intent-filter> </er ER> <! -- Start the activation page --> <activity android: name = "com. home. util. StartDeviceManagerActivity" android: theme = "@ style/TransparentActivity"/>
Device_admin.xml:
<device-admin xmlns:android="http://schemas.android.com/apk/res/android"> <uses-policies> <wipe-data /> </uses-policies></device-admin>