當前位置: 首頁>>代碼示例>>Java>>正文


Java DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN屬性代碼示例

本文整理匯總了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);
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:16,代碼來源:PolicySetupActivity.java

示例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();
    }
}
 
開發者ID:firebirdberlin,項目名稱:nightdream,代碼行數:18,代碼來源:PreferencesFragment.java

示例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);
    }
}
 
開發者ID:wso2-attic,項目名稱:product-emm,代碼行數:21,代碼來源:MainActivity.java

示例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;
}
 
開發者ID:xmikos,項目名稱:SnooperStopper,代碼行數:17,代碼來源:MainActivity.java

示例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);
    }
 
開發者ID:enricocid,項目名稱:LaunchEnr,代碼行數:7,代碼來源:PermissionUtils.java

示例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;
    }
}
 
開發者ID:sdrausty,項目名稱:buildAPKsSamples,代碼行數:14,代碼來源:SecureNoteActivity.java

示例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();

}
 
開發者ID:shenhuanet,項目名稱:AndroidOpen,代碼行數:9,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:seguri,項目名稱:Lock,代碼行數:7,代碼來源:MainActivity.java

示例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);
}
 
開發者ID:aidansu,項目名稱:Lockscreen,代碼行數:7,代碼來源:MainActivity.java

示例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);
	}
}
 
開發者ID:saki4510t,項目名稱:libcommon,代碼行數:9,代碼來源:DeviceAdminReceiverLock.java

示例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);
}
 
開發者ID:ZalemSoftware,項目名稱:OpenMobster,代碼行數:7,代碼來源:PolicyManager.java

示例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);
}
 
開發者ID:tortuvshin,項目名稱:memorize,代碼行數:7,代碼來源:Settings.java

示例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);
    }
}
 
開發者ID:jplitza,項目名稱:DeviceAdministrator,代碼行數:33,代碼來源:SettingsActivity.java

示例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);
}
 
開發者ID:li-yu,項目名稱:iTester,代碼行數:9,代碼來源:MainActivityWiperReceiver.java

示例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);
}
 
開發者ID:zqWu,項目名稱:cordova_pulgin_mdm,代碼行數:12,代碼來源:MdmExecutor.java


注:本文中的android.app.admin.DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。