• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Disable Camera on Android Devices

I have been going through forums and blogs where developers queried about disabling camera on android devices. Its pretty much easy. Here is how.

You need to use Device Admin privileges to have the rights to disable the camera. Remember that once an app is registered as Device Admin, it can only be uninstalled if the permissions from Device Admin (Settings section on your android device) is given.

1. Make a class (e.g. DevicePolicyActivity) and extend Activity
1.1 . Make another class (e.g. AndroidDeviceAdminReceiver) and extend DeviceAdminReceiver

2. Make two variables like...

DevicePolicyManager devicePolicyManager;
ComponentName demoDeviceAdmin;

3. Initialize the variables above in onCREATE function like....
devicePolicyManager = (DevicePolicyManager) getSystemService(Context.DEVICE_POLICY_SERVICE);

demoDeviceAdmin = new ComponentName(this, AndroidDeviceAdminReceiver.class);

4. Now, add disable camera function against your button press or checkbox function as...

devicePolicyManager.setCameraDisabled(demoDeviceAdmin, false);

5. Now, add Intent to your class like...

private void activateDevicePolicyAdmin() {
Intent intent = new Intent(
DevicePolicyManager.ACTION_ADD_DEVICE_ADMIN);
intent.putExtra(DevicePolicyManager.EXTRA_DEVICE_ADMIN,
demoDeviceAdmin);
intent.putExtra(DevicePolicyManager.EXTRA_ADD_EXPLANATION,
"Organization Policy ");
startActivityForResult(intent, ACTIVATION_REQUEST);
}

protected void onActivityResult(int requestCode, int resultCode, Intent data) {
switch (requestCode) {
case ACTIVATION_REQUEST:
if (resultCode == Activity.RESULT_OK) {
Log.i(TAG, "Administration enabled!");
} else {
Log.i(TAG, "Administration enable FAILED!");
}
return;
}
super.onActivityResult(requestCode, resultCode, data);
}

Read further at DISABLE CAMERA
 
Back
Top Bottom