AloysiusG
AloysiusG

Reputation: 13

Enable Device's Camera App in Android Management API Policy

My app calls the device's camera app using:

Intent pictureIntent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);


    if (pictureIntent.resolveActivity(getPackageManager()) != null) {

        File file = null;
        try {
            file = createImageFile();
            Log.d(TAG, "created imagefile ");
        } catch (IOException e) {
            e.printStackTrace();
            return;
        }
        Uri photoUri = FileProvider.getUriForFile(this, getPackageName() + ".provider", file);
        Log.d(TAG, "openCamera: " + photoUri);
        pictureIntent.putExtra(MediaStore.EXTRA_OUTPUT, photoUri);


        startActivityForResult(pictureIntent, MY_PERMISSIONS_REQUEST_CAMERA);
    }

When using the app in a provisioned device with "cameraDisabled": false I still cannot load the camera.

My policy is:

{ "applications": [{ "packageName": "**************", "installType": "FORCE_INSTALLED", "defaultPermissionPolicy": "GRANT" }], "debuggingFeaturesAllowed": true, "addUserDisabled": true, "adjustVolumeDisabled": true, "outgoingCallsDisabled": true, "locationMode": "HIGH_ACCURACY", "cameraDisabled": false, "screenCaptureDisabled": true, "defaultPermissionPolicy": "GRANT", "wifiConfigDisabled": false, "dataRoamingDisabled": false, "smsDisabled": true, "factoryResetDisabled": false, "uninstallAppsDisabled": true, "tetheringConfigDisabled": true, "shareLocationDisabled": false, "funDisabled": true, "appAutoUpdatePolicy": "WIFI_ONLY", "systemUpdate": { "type": "WINDOWED", "startMinutes": 10, "endMinutes": 1430 }, "kioskCustomLauncherEnabled":true, "kioskCustomization": { "deviceSettings": "SETTINGS_ACCESS_ALLOWED" } }

UPDATE: I ended up using the the CameraX library to create my own camera instead.

Upvotes: 0

Views: 852

Answers (1)

Sudhu
Sudhu

Reputation: 587

You would have probably disabled system apps during enrollment in the QR code.

Now for your question, you will have to find the package name of the default camera app of the device and just enable it in the policy.

For example, Snapdragon Camera is the default on my Zebra devices :

  "applications": [
    {
      "packageName": "org.codeaurora.snapcam",
      "installType": "FORCE_INSTALLED"
    }
  ]
}

I know the camera app would be different for each device brand but with system apps disabled, this is the way that I've been using.

Upvotes: 0

Related Questions