List of usage examples for android.app.admin DevicePolicyManager EXTRA_DEVICE_ADMIN
String EXTRA_DEVICE_ADMIN
To view the source code for android.app.admin DevicePolicyManager EXTRA_DEVICE_ADMIN.
Click Source Link
From source file:com.dudu.aios.ui.activity.MainRecordActivity.java
private void activeManage() { // ??(??Intent) - AndroidManifest.xml Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); // ??//from ww w. ja v a 2 s . co m intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName); // ??(additional explanation) ????? intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "???"); startActivityForResult(intent, MY_REQUEST_CODE); }
From source file:org.wso2.iot.agent.activities.AuthenticationActivity.java
/** * Start device admin activation request. * *//*from www .j a va 2s . c o m*/ private void startDeviceAdminPrompt() { if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP && devicePolicyManager.isProfileOwnerApp(getPackageName())) { checkManifestPermissions(); CommonUtils.callSystemApp(context, null, null, null); Log.i("onActivityResult", "Administration enabled!"); } else { DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService( Context.DEVICE_POLICY_SERVICE); ComponentName cdmDeviceAdmin = new ComponentName(AuthenticationActivity.this, AgentDeviceAdminReceiver.class); if (!devicePolicyManager.isAdminActive(cdmDeviceAdmin)) { Intent deviceAdminIntent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); deviceAdminIntent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cdmDeviceAdmin); deviceAdminIntent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getResources().getString(R.string.device_admin_enable_alert)); startActivityForResult(deviceAdminIntent, ACTIVATION_REQUEST); } } }
From source file:org.durka.hallmonitor.CoreStateManager.java
public void requestAdmin() { if (!adminApp && preference_all.getBoolean("pref_lockmode", false) && configurationActivity != null) { ComponentName me = new ComponentName(mAppContext, AdminReceiver.class); Log.d(LOG_TAG, "launching dpm overlay"); mAppContext.startActivity(new Intent(getContext(), Configuration.class) .addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS)); Log.d(LOG_TAG, "Started configuration activity."); Intent coup = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); coup.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, me); coup.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, mAppContext.getString(R.string.admin_excuse)); getConfigurationActivity().startActivityForResult(coup, CoreApp.DEVICE_ADMIN_WAITING); }//ww w . ja v a 2s. c o m }
From source file:com.sentaroh.android.TaskAutomation.Config.ActivityMain.java
final private void switchDeviceAdminStatus(boolean activate) { DevicePolicyManager dpm = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE); final ComponentName darcn = new ComponentName(mContext, DevAdmReceiver.class); if (activate && !dpm.isAdminActive(darcn)) { NotifyEvent ntfy = new NotifyEvent(mContext); ntfy.setListener(new NotifyEventListener() { @Override//from ww w. ja v a 2s. c om public void positiveResponse(Context c, Object[] o) { Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN); intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, darcn); startActivityForResult(intent, 10); } @Override public void negativeResponse(Context c, Object[] o) { } }); if (mApplicationRunFirstTime) { mGlblParms.commonDlg.showCommonDialog(false, "I", mContext.getString(R.string.msgs_main_screen_lock_confirm_title), mContext.getString(R.string.msgs_main_screen_lock_confirm_msg), ntfy); } else ntfy.notifyToListener(true, null); } else if (!activate) dpm.removeActiveAdmin(darcn); }