本文整理汇总了Java中android.app.admin.DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN属性的典型用法代码示例。如果您正苦于以下问题:Java DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN属性的具体用法?Java DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN怎么用?Java DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN使用的例子?那么恭喜您, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类android.app.admin.DevicePolicyManager
的用法示例。
在下文中一共展示了DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN属性的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onClick
@Override
public void onClick(View v) {
// First, persist the policy. Then, launch intent to trigger the system screen
// requesting user to confirm the activation of the device administrator.
writePolicy();
Intent activateDeviceAdminIntent =
new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
activateDeviceAdminIntent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
mPolicy.getPolicyAdmin());
// It is good practice to include the optional explanation text to explain to
// user why the application is requesting to be a device administrator. The system
// will display this message on the activation screen.
activateDeviceAdminIntent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
getResources().getString(R.string.device_admin_activation_message));
startActivityForResult(activateDeviceAdminIntent, REQ_ACTIVATE_DEVICE_ADMIN);
}
示例2: setupDeviceAdministratorPermissions
private void setupDeviceAdministratorPermissions(SharedPreferences sharedPreferences) {
if (!isAdded() ) return;
boolean on = sharedPreferences.getBoolean("useDeviceLock", false);
if (on) {
DevicePolicyManager mgr = (DevicePolicyManager) mContext.getSystemService(Context.DEVICE_POLICY_SERVICE);
ComponentName cn = new ComponentName(mContext, AdminReceiver.class);
if ( !mgr.isAdminActive(cn)) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, cn);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
getString(R.string.useDeviceLockExplanation));
startActivity(intent);
}
} else {
removeActiveAdmin();
}
}
示例3: startDeviceAdminPrompt
/**
* Start device admin activation request.
*
* @param cdmDeviceAdmin - Device admin component.
*/
private void startDeviceAdminPrompt(ComponentName cdmDeviceAdmin) {
DevicePolicyManager devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);
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);
} else {
Intent intent = new Intent(Intent.ACTION_MAIN);
intent.addCategory(Intent.CATEGORY_HOME);
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_CLEAR_TOP |
Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intent);
}
}
示例4: onPreferenceChange
@Override
public boolean onPreferenceChange(Preference pref, Object newValue) {
boolean isChecked = (boolean) newValue;
if (isChecked) {
Log.d(TAG, "switchAdmin.isChecked() == true");
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, snooperStopperDeviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"Monitors failed unlock attempts and shutdowns phone if limit is reached");
startActivityForResult(intent, ACTIVATION_REQUEST);
} else {
Log.d(TAG, "switchAdmin.isChecked() == false");
devicePolicyManager.removeActiveAdmin(snooperStopperDeviceAdmin);
updateSwitchAdminHandler.postDelayed(updateSwitchAdminRunnable, 1000);
}
return true;
}
示例5: askForAdmin
public static void askForAdmin(Activity activity) {
ComponentName mComponentName = new ComponentName(activity, AdminReceiver.class);
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mComponentName);
activity.startActivity(intent);
}
示例6: enableDeviceAdmin
private boolean enableDeviceAdmin() {
if (this.isDeviceAdminEnabled()) {
Log.d(TAG, "Device Admin is already active!");
return true;
} else {
Log.d(TAG, "Device Admin is not active. Requesting it to be enabled");
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, this.deviceAdminComponentName);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
super.getText(R.string.device_admin_explanation));
super.startActivityForResult(intent, ENABLE_DEVICE_ADMIN_REQUEST);
return false;
}
}
示例7: activeManager
private void activeManager() {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, name);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getString(R.string.app_name));
startActivity(intent);
createShortcut();
}
示例8: enableAppAsAdministrator
private void enableAppAsAdministrator() {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, mCN);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, getString(R.string.receiver_expl));
i("startActivityForResult: requestCode=%d", REQUEST_CODE_ENABLE_ADMIN);
startActivityForResult(intent, REQUEST_CODE_ENABLE_ADMIN);
}
示例9: startAddDeviceAdminAty
private void startAddDeviceAdminAty(){
String info = getResources().getString(R.string.info);
Intent i = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
i.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,Dar.getCn(this));
i.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,info);
startActivityForResult(i, REQUEST_CODE_ADD_DEVICE_ADMIN);
}
示例10: requestScreenLock
public static void requestScreenLock(final Activity activity, final boolean finish) {
if (!checkScreenLock(activity, finish)) {
// スクリーンをロックできなかった時はデバイス管理者が無効になってるはずなのでデバイス管理者有効画面を表示する
final Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, new ComponentName(activity, DeviceAdminReceiverLock.class));
intent.putExtra(EXTRA_REQUEST_FINISH, finish);
activity.startActivityForResult(intent, REQ_SCREEN_LOCK);
}
}
示例11: showAdminScreen
public void showAdminScreen(Activity parent)
{
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, deviceAdminReceiver);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,"");
parent.startActivityForResult(intent, 1);
}
示例12: startEnableAdminIntent
private void startEnableAdminIntent() {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, componentName);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"Дэлгэцэн дээр шинэ товч гаргах");
startActivityForResult(intent, RESULT_ENABLE);
}
示例13: onRequestPermissionsResult
@Override
public void onRequestPermissionsResult(
int requestCode,
@NonNull String[] permissions,
@NonNull int[] grantResults
) {
boolean granted = true;
boolean need_device_admin = false;
for (String perm : perms.valueAt(requestCode)) {
for (int i = 0; i < permissions.length; i++) {
if (permissions[i].equals(perm)) {
if (perm.equals(Manifest.permission.BIND_DEVICE_ADMIN)) {
need_device_admin = true;
} else {
granted = grantResults[i] == PackageManager.PERMISSION_GRANTED;
}
break;
}
}
if (!granted)
break;
}
if (granted && need_device_admin) {
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, DeviceAdmin.getComponentName(this));
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, findPreference(perms.keyAt(requestCode)).getSummary());
startActivityForResult(intent, requestCode);
}
else {
Log.d("RequestPermissionsResul", "Setting checkbox " + perms.keyAt(requestCode) + " to " + granted);
((CheckBoxPreference)findPreference(perms.keyAt(requestCode))).setChecked(granted);
}
}
示例14: getAdmin
public void getAdmin() {
// Launch the activity to have the user enable our admin.
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
mDeviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"ع���Ʒ��������Ʒ!");
startActivityForResult(intent, RESULT_ENABLE);
}
示例15: active
public void active(Activity act) {
if (isActive()) {
Log.i(TAG, "mdm actived");
return;
}
Log.i(TAG, "try activy mdm by =" + act.getClass().getName());
Intent intent = new Intent(DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN, adminName);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION, "press button to active mdm");
act.startActivityForResult(intent, REQUEST_CODE_MDM);
}