0

In Android 12 google introduced users can enable and disable camera and microphone access for all apps on the device by pressing a single toggle option. For more information visit here.

As per documentation we can check which device support toggle mode for camera and microphone by using following code

SensorPrivacyManager sensorPrivacyManager = getApplicationContext()
        .getSystemService(SensorPrivacyManager.class);
boolean supportsMicrophoneToggle = sensorPrivacyManager
        .supportsSensorToggle(Sensors.MICROPHONE);
boolean supportsCameraToggle = sensorPrivacyManager
        .supportsSensorToggle(Sensors.CAMERA);

As per documentation The camera and microphone toggles affect all apps on the device:

  1. When the user turns off camera access, your app receives a blank camera feed.
  2. When the user turns off microphone access, your app receives silent audio.

My question is Is there any way to observe toggle state of camera and microphone so we can prevent streaming blank camera and silent audio?

If you go through SensorPrivacyManager class in Android Studio you will find there is addSensorPrivacyListener but we can not implement it as its accessible if we use it as system application.

Saurabh Bhandari
  • 2,438
  • 4
  • 26
  • 33
  • Yes sort of but I am trying to find is there any way using audio manager or sensor manager to get rid of this problems – Saurabh Bhandari May 17 '22 at 16:04
  • 1
    A different approach would be to detect silence or blank video and then notify the user that privacy settings may be enabled, assuming the user isn't in a dark room / not speaking. – Morrison Chang May 17 '22 at 17:48

0 Answers0