Android - disable proximity sensor in my application

I am working on an application that allows the user to start a phone call from the application itself, and as soon as the call has been initiated, the user can return to the application to perform some user interface actions.

My current problem is that after starting the call, the proximity sensor was turned on, because of which it is almost impossible to work with the application (depending on the sensitivity of the sensor - on the device).

In any case, to control the sensor? For example, I would like to turn off the sensor as soon as my activity is visible, and turn it on again as invisible.

Thanks, Lior.

+4
source share
1 answer

Try installing WakeLock in the application code ... as shown below.

 PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock( PowerManager.FULL_WAKE_LOCK, "FullWakeLock" ); 

Hope this helps you ...

+3
source

Source: https://habr.com/ru/post/1435040/


All Articles