5

I have an app that places a phone call and then switches back to my activity while the phone call is happening. The problem is, if the user puts their hand near the proximity sensor, then the screen turns off. Is there a way to disable the proximity sensor from turning off the phone when in a phone call?

I have tried using a PROXIMITY_SCREEN_OFF_WAKE_LOCK and FULL_WAKE_LOCK; I have tried using Window flags (WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED | WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD); and I have tried using myView.setKeepScreenOn(true). All have been unsuccessful so far.

Also, I have a listener for ACTION_SCREEN_OFF and ACTION_SCREEN_ON so if the user presses the power button for whatever reason, then it will end the call.

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
Chris Feist
  • 1,678
  • 15
  • 17
  • That should be a setting of the phone app and nothing you can control. Why is it a problem? You usually have the phone near your head wile in a call and the proximity sensor prevents you from accidentially touching buttons with your cheek (+ saves battery because display can be off) – zapl Apr 27 '12 at 19:28
  • I understand how it is useful in most cases. An example of where you'd want the screen on though, is if my app is to display the audio quality of the phone call in real time. Like if a known audio track was being sent through the call, then the phone output was compared to the original. There is no need for the user to listen to the call in this case and then they can see the results live. My temporary solution is to not end the call using the screen on/off listener; hence, no way to detect power button either. – Chris Feist May 17 '12 at 21:30
  • Another scenario is when you're on a conference call, and during this call, you want to mute your end so you can do something before resuming the call again. So, if the proximity sensor is off during call, the default option is you may have to press a button on the device in order to turn the phone screen's back on to un-mute yourself. AOSP needs to have a public method to turn proximity sensor off during call... – ChuongPham Jan 21 '14 at 22:14
  • Did you ever get around this? – Binoy Babu Dec 20 '14 at 17:10
  • @BinoyBabu I think you should try acquiring the wake lock from a background service. Acquire the wake lock in onStartCommand of the Service and release it in onDestroy. Then start and stop the service as required. – Shivam Verma Dec 20 '14 at 17:40
  • @BinoyBabu No I didn't. I tried several different ways. Acquiring the wakelock doesn't work either. Under the covers, the Phone app uses [PowerManager.PROXIMITY_SCREEN_OFF_WAKE_LOCK](http://developer.android.com/reference/android/os/PowerManager.html#PROXIMITY_SCREEN_OFF_WAKE_LOCK) which seems to have higher priority than other wakelocks. – Chris Feist Dec 22 '14 at 17:28
  • Thanks Chris. Time to move on i guess. – Binoy Babu Dec 22 '14 at 17:36
  • Your problem seems exact opposite to the following [problem and to his answer][1]. [1]: http://stackoverflow.com/q/21884181/1061944 – Murtaza Khursheed Hussain Dec 24 '14 at 13:49

0 Answers0