• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Help Use proximity sensor to disable screen while in pocket

Status
Not open for further replies.
There's no particular reason I would keep this really simple stuff to myself. I wrote here down everything that counts which is why I didn't see I should've given any code away.
Now I'm evaluating the usage of the device and I've found out that the service should start when the screen got locked and should stop when someone has manually (!) unlocked it. But I'm afraid there's no way to determine that the screen was unlocked by the user itself. This is important since there are some apps (like the dialer) that unlockes the screen. While in a call there's no problem because Android's own proximity sensing is active. But after hanging up, the screen gets unlocked (but not every time! :-D). This is where we have to decide what to do. There could be a workaround that when a call ends, the proximity service should stay on for a period of time (eg. lock screen timeout) and go off (stop sensing) when this time ends AND the device is still unlocked. Or stay on if the screen is locked. This could be a general solution and it wouldn't depend on earplugs and so on. Still playing with the idea.
Anyway. The code is available here:
proximitytoolextension - Project Hosting on Google Code
 
I am going to be very simple here as there is a lot of talk that is going over my head.

When I am in calls the proximity sensor drives me mad, maybe mine doesn't work correcltly, but it cosntantly flickers the screen on and off.

Is there any way I can just turn the proximity sensor off altogether?
 
I am going to be very simple here as there is a lot of talk that is going over my head.

When I am in calls the proximity sensor drives me mad, maybe mine doesn't work correcltly, but it cosntantly flickers the screen on and off.

Is there any way I can just turn the proximity sensor off altogether?

Take off anything that surrounds it. Do you have a case maybe?
 
I've made some progression with this tool. Please evaluate it, I'm very interested regarding your opinions. Thanks.
The features by now:

Screen goes to sleep when in proximity and one of the following conditions are met:
- wired headset is plugged in
- bluetooth headset is connected
- phone goes idle (call gets hung up) BUT only for the period of the lock timeout. The reason for this: when you hang up on a call the screen either wakes or unlocks itself. This is unacceptable bacause if in your pocket it starts to dial or goes crazy because the random unlock pattern does not match. With the help of this tool you can get rid of the unlock pattern if you don't need it
- phone starts ringing. I always have a problem picking up a call when taking the device out of my pocket. I accidentally reject it by leg-moving the slider upways. This is also eliminated with the use of the tool

Proximity sensing stops when:
- disconnecting the headphones or bluetooth headset
- call is picked up (the system's built-in sensing takes over)
- call goes idle and screen times out (lock screen timeout period). The default lock and idle screen takes over

Future plans:
- proximity sensing should be enabled after events also (sms, calendar). And of course it activates only when screen is locked in the moment
- suggestions?

Binary package:
http://proximitytoolextension.googlecode.com/files/ProximityTool.apk

Source:
http://proximitytoolextension.googlecode.com/files/ProximityTool.src.eclipse-ga.zip

Remember: turning the screen off AND locking the screen are NOT the same. When screen's turned off, the screen is blank and keypresses are ignored. When screen is locked, it's not blank, you just can not reach the device's functions before unlocking it.
 
- phone starts ringing. I always have a problem picking up a call when taking the device out of my pocket. I accidentally reject it by leg-moving the slider upways. This is also eliminated with the use of the tool

I have that problem too. Your app prevents this successfully, but it prevents the phone from ringing altogether also when something is near..... (tested by keeping my hand on the sensor and calling the Desire. At the moment i remove my hand, only then the Desire starts ringing). If this is fixed, you have a killer app.
 
I have that problem too. Your app prevents this successfully, but it prevents the phone from ringing altogether also when something is near..... (tested by keeping my hand on the sensor and calling the Desire. At the moment i remove my hand, only then the Desire starts ringing). If this is fixed, you have a killer app.

??? There must not be any connection between ringing and blanking the screen. Check it again please. I use this for days but no such experience. Don't you use any other tool similar to this? I still don't see any reason why it would happen that you described.
 
??? There must not be any connection between ringing and blanking the screen. Check it again please. I use this for days but no such experience. Don't you use any other tool similar to this? I still don't see any reason why it would happen that you described.

Will try again tonight. Was not using any other blocking/locking program (i have Lock 2.0 installed, but it wasn't running at the time)
 
I've made some progression with this tool. Please evaluate it, I'm very interested regarding your opinions. Thanks.
The features by now:

Screen goes to sleep when in proximity and one of the following conditions are met:
- wired headset is plugged in
- bluetooth headset is connected
- phone goes idle (call gets hung up) BUT only for the period of the lock timeout. The reason for this: when you hang up on a call the screen either wakes or unlocks itself. This is unacceptable bacause if in your pocket it starts to dial or goes crazy because the random unlock pattern does not match. With the help of this tool you can get rid of the unlock pattern if you don't need it
- phone starts ringing. I always have a problem picking up a call when taking the device out of my pocket. I accidentally reject it by leg-moving the slider upways. This is also eliminated with the use of the tool

Proximity sensing stops when:
- disconnecting the headphones or bluetooth headset
- call is picked up (the system's built-in sensing takes over)
- call goes idle and screen times out (lock screen timeout period). The default lock and idle screen takes over

Future plans:
- proximity sensing should be enabled after events also (sms, calendar). And of course it activates only when screen is locked in the moment
- suggestions?

Binary package:
http://proximitytoolextension.googlecode.com/files/ProximityTool.apk

Source:
http://proximitytoolextension.googlecode.com/files/ProximityTool.src.eclipse-ga.zip

Remember: turning the screen off AND locking the screen are NOT the same. When screen's turned off, the screen is blank and keypresses are ignored. When screen is locked, it's not blank, you just can not reach the device's functions before unlocking it.

Copas, you are doing a great job. Thanks!

I am testing the PT for a couple of days, and I'll get back to you.
 
You are my prince! You've set me free of sooo much buttheart! Now, thanks to you, i can listen to the music on the road, pick up the phone by my wired headset, end the call by it and continue to listen and skip tracks by it.

I am switcher from iPhone and this features worked right out of the box on it. Now i have all of the advantages from Android plus comfortable usage with wired 1-button headset.

Registered just to say thank you very much.
 
I have the same problem of ringing people when the phone is in my pocket. I have installed this app & it's a running service but I just can't see how it works different from before?

Please explain to the layman thankyou :)
 
When you make a call you put the phone to your face which is the same as putting your hand over the display. Surly you want to prevent the phone making a call when the proximity sensor registers something?
 
When you make a call you put the phone to your face which is the same as putting your hand over the display. Surly you want to prevent the phone making a call when the proximity sensor registers something?
:)
It doesn't prevent any making of a call. It just turns on proximity sensing (turning off the display and ignores keypresses) for the period of what has been described in earlier posts.
 
Copas2, the proximity tool is not ready for the app of the year award yet.

I have it turned on, and I can see that it works by testing it with my hands. However, when I put it into my pocked the buttons are still pressed after i receive a call. My hypothesis, is that in certain positions the phone is too far away from the "pocket-wall" and the screen turns on, and this is when the button gets pressed.

As I understand, there is no way to force the screen-lock to come on after the PS turns the screen off. But is there a way to increase the time period between the removal of stimuli to the PS and awakening? So that it takes, say 3 seconds of no proximity to awake the screen, otherwise it remains turned off.
 
I don't really understand, sorry. But try this first. I've made some changes to the moment the call finishes.
http://proximitytoolextension.googlecode.com/files/ProximityTool.apk
After the call the proximity sensor starts but whilest the screen times out it periodically checks (5-5 seconds) if the screen is on. If it is, it stops. I personally like it this way already.
There is one more thing left though. At least at the moment there seems to be only one thing actually. A sudden calendar alert wakes the phone and places a damn snooze button on the screen. After that event the prox. sensor should be activated just like when ringing, etc. This is the event which I'm looking after right now but haven't found yet. Patience... :)
 
My HERO would actually make calls while in my pocket so I put a lock pattern on it.
Now, I can't even use the phone because the lock pattern was tried too many times in my pocket.:(
Once I get it working again I am going back to a case.
 
A new phenomenon has turned up: the proximity sensor app is blanking the screen also when the phone is not locked and i'm just using it.... Stopping and restarting the service solves that, but i wonder how this has happened.

Some background info: I'm using the standard vertical slider lock. The phone has been running one day and one night since boot. At night, i set the phone in a deskstand with the standard nightclock running.
 
A new phenomenon has turned up: the proximity sensor app is blanking the screen also when the phone is not locked and i'm just using it.... Stopping and restarting the service solves that, but i wonder how this has happened.
Read previous posts. It holds proximity sensing 'till screen timeout. But please, install the latest. The previous versions will always be far from good.
 
Copas2, the proximity tool is not ready for the app of the year award yet.

I have it turned on, and I can see that it works by testing it with my hands. However, when I put it into my pocked the buttons are still pressed after i receive a call. My hypothesis, is that in certain positions the phone is too far away from the "pocket-wall" and the screen turns on, and this is when the button gets pressed.

As I understand, there is no way to force the screen-lock to come on after the PS turns the screen off. But is there a way to increase the time period between the removal of stimuli to the PS and awakening? So that it takes, say 3 seconds of no proximity to awake the screen, otherwise it remains turned off.

gergohad,

I am yet to try this app, (my phone will arrive Monday :-) but it occurs to me that possibly you may have differing results depending which way around you phone is in your pocket. Is the prox. sensor towards your body or away.

If away and your pocket material is thin enough then it is possible that the prox. sensor is not registering or only registering intermittently?

Just a suggestion...

Dave.
 
Yes, I've tried both PS facing out, and PS facing in. I've also tried putting the phone into my pocked up-side-down. So that the PS in in the bottom of the pocket.
 
Hello,
this is my first post and I hope I didn't miss a post above saying what I want.

Your app is great but its still kinda buggy.
When I enable it and put in the headphones (what actually enables the app automatically) the screen goes off as intended after the display timeout.
But when I put my finger on the proximity sensor and remove it again the display goes on! It should still stay off now! When I put my finger again over the PS it goes off. Finger away -> on.

To make a long story short:
Can't the app just go ON when the display goes on? And let your app go OFF when the display goes off.
When the display timeouts it should be ONLY unlocked/enabled BY the USER, not by your app.
Now your App does automatically awake the screen when there's nothing above the sensor.
 
Status
Not open for further replies.
Back
Top Bottom