当前位置: 首页>>代码示例>>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;未经允许,请勿转载。