Lior Ohana
Lior Ohana

Reputation: 3527

Android - Disable proximity sensor in my app

I'm working on an app that allows the user to start a phone call from the app itself and once the call was initiated, the user can get back to the app to do some UI actions.

My current problem is that once the call started the proximity sensor was enabled which makes it almost impossible to work with the app (depends on the sensitivity of the sensor - per device).

Is there anyway to control the sensor? For example, I would like to disable the sensor once my activity is visible and re-enable it once invisible.

Thanks, Lior.

Upvotes: 4

Views: 3985

Answers (1)

Priyank Patel
Priyank Patel

Reputation: 12362

Try to set WakeLock in your application code...like below....

PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE);

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

Hope it will help you...

Upvotes: 3

Related Questions