• 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.
Ok but I can't wait for screen timeout each time! And I noticed that the sensor turns on only after some time (15-30 seconds after the screen gets dark, and not always).
On the contrary if I lock the phone with the physical key or with an app (screen off and lock, widgetsoid, beautiful widget etc...) the sensor is activated immediately, but I can't wake the phone without the physical key.

I don't know if it matters but I have a Galaxy S2 with 2.3.4 rooted stock rom (I found the topic googleing, only now I notice this is a htc section)
 
I've found a bit of a problem with this app. I just updated from the older "proximity tool" to Proximity Service 1.3. I have the Event Controlled option ticked, and this is on a Desire with the "official" Gingerbread update.

Here's the scenario. I have my Desire lying on my desk, with the screen off and locked. I then press the power button to activate the screen to check the status bar, without unlocking the device. Having done that, I press the power button again to turn the screen off.

The problem is that, because the device is still locked, and because the proximity sensor is right next to the power button, the proximity service activates just before I switch the screen off, when my hand approaches the button. Consequently, my button press is ignored by the device, and when I move my hand away, the screen comes back on.

The only way to turn my screen off in this locked situation is to (a) wait for it to time out by itself, (b) unlock the device and then switch it off, or (c) very carefully press the button without allowing my hand to go near the prox sensor.

Can you think of some clever way to stop this from happening e.g. only have the service active when the phone is locked with the screen off?
May be just disable the service when power button pressed manually?
Manual screen state change from OFF to ON - service turns off.
Manual screen state change from ON to OFF - service turns on.
This algorithm can help to avoid the scenario described.
 
Been looking everywhere for this. Well done.

One idea/suggestion.

A 10 second time out, If the phone is woken in your pocket, if the proximity stays for more than 10 seconds (without being allowed screen on), the phone is sent back to sleep. I placed a coin on my sensor, woke the phone up (but screen is off), waited 5 minutes, then when I removed the coin, the screen woke up . This means the sensor was active for the entire time. Without the Proximity tool, you are only permitted a few seconds to slide to unlock before the screen blanks, even if your touching the screen, you *still* have to unlock the phone or it will sleep again. I suspect the phone could be woken in my pocket, and the tool will not allow the phone to sleep again until i remove it from my pocket, as the phone is no longer in *standby* (yet the screen is off) it could suck battery power.

Thanks Again & have a great New Year.

Kym

NOTE: Just found that if "Anything" wakes the phone up, the proximity sensor stays on, until you unlock. Even sitting on my work desk, if i tap "Menu" the phone wakes up, after the screen times out and goes out, the proximity sensor is still on, as I can just wave my hand over the phone, and it magically comes to life. Is the sensor supposed to stay on, even if the phone has gone to sleep?
 
Been looking everywhere for this. Well done.

One idea/suggestion.

A 10 second time out, If the phone is woken in your pocket, if the proximity stays for more than 10 seconds (without being allowed screen on), the phone is sent back to sleep. I placed a coin on my sensor, woke the phone up (but screen is off), waited 5 minutes, then when I removed the coin, the screen woke up . This means the sensor was active for the entire time. Without the Proximity tool, you are only permitted a few seconds to slide to unlock before the screen blanks, even if your touching the screen, you *still* have to unlock the phone or it will sleep again. I suspect the phone could be woken in my pocket, and the tool will not allow the phone to sleep again until i remove it from my pocket, as the phone is no longer in *standby* (yet the screen is off) it could suck battery power.

Thanks Again & have a great New Year.

Kym

NOTE: Just found that if "Anything" wakes the phone up, the proximity sensor stays on, until you unlock. Even sitting on my work desk, if i tap "Menu" the phone wakes up, after the screen times out and goes out, the proximity sensor is still on, as I can just wave my hand over the phone, and it magically comes to life. Is the sensor supposed to stay on, even if the phone has gone to sleep?

No, not really. If you look into the sources, you'll find that it's not me who does this kinda "magic" :). This is just how Android 2.3.3 works in the moment.
I've been thinking about the same that I could try to send the device to sleep after some preset time (not the one defined in the Display preferences because that reads 10 minutes in my case :) ). I'll definitely look into that in the near future.
 
dear copas2
i used the proximity code-- many many thanks -- but what is the zip file next to it on the same page please???
Hi,
that file is only for the HTC Desire (Bravo) and makes some changes in the key mapping/handling so that the device doesn't wake up when the power key is pressed. This goes only for custom roms which have the ability to wake the device with the trackpad button. This is reasonable because the Desire has a very easy pushable power button and the device comes alive if you slide it in your pocket heads down.
 
I made a 5-10 line code of service which needs to be started every time you bike :-) and stopped when resuming normal usage (not anymore, see later post). It would be annoying to have it always on.
Starting it toggles the service on and off. The task is very simple. While the service is active it turns the screen off every time when something's near and turns it back on when far. It means the screen will (should) be turned off (not locked) by it while in pocket. The very same like while in a call.
The service consumes nothing. It neither does poll nor run anything. When turned on, it just "aquires" a PowerManager.WakeLock (PROXIMITY_SCREEN_OFF_WAKE_LOCK (32)). Turning it off, that WakeLock will be released. The system does the actual screen toggling. The apk was packaged against and run on Android version 2.1. I don't see why it shouldn't run on 2.2 or even earlier releases. The device is an HTC Desire. It should run on any other device which has a proximity sensor built in and implemented towards Android. Task Killer users should check their settings and append this to the exception list of course.

The service can be found here: (old link removed)


You use it of course on your own responsibility :-).

Since I don't really have enough time to dive into the SDK of Android in the moment, for a week or two I just can't make any progress with this. But I'm thinking about implementing some improvements. It might be useful if the screen would only go off when attaching headphones. I'm open to ideas of course.

Ok. First at all, sorry about my english, it's very poor.

This it's the situation, i've just register here to say THANK YOU for the application.

I have 2 phones ( Galaxy S2 and a Droid 3 ) , and in the Droid 3 i've tried a lot of applications to avoid the use of the power button for screenoff and do the same thing that this application do. This one it's the only that's works just PERFECT. The others applications ( even professional ones ) fails in somewhere ( ex: cant keep the sensors turned on for some reason and fails when i try to turn on again the screen with my hand)

On the configuration, the only thing that i have to turn off it's the "event controlled" but after turned off that, the application works perfect. I've tested the aplic under phone calls, etc and works fine on all scenarios.

When i use the power button on my droid, the application stop running, but when i turn on the phone with the power button again, the application starts. So i have the chance to turn off the application for a moment without shooting down and starting again the service. Just excelent !

I've not noticed about battery drain also. I asume that the battery maybe will be penalized a little but, its worth it.

Nothing more to say.

Thanks a lot again and greetings from Argentina !
 
This it's the situation, i've just register here to say THANK YOU for the application.

I have 2 phones ( Galaxy S2 and a Droid 3 ) , and in the Droid 3 i've tried a lot of applications to avoid the use of the power button for screenoff and do the same thing that this application do. This one it's the only that's works just PERFECT. The others applications ( even professional ones ) fails in somewhere ( ex: cant keep the sensors turned on for some reason and fails when i try to turn on again the screen with my hand)

On the configuration, the only thing that i have to turn off it's the "event controlled" but after turned off that, the application works perfect. I've tested the aplic under phone calls, etc and works fine on all scenarios.

When i use the power button on my droid, the application stop running, but when i turn on the phone with the power button again, the application starts. So i have the chance to turn off the application for a moment without shooting down and starting again the service. Just excelent !

I've not noticed about battery drain also. I asume that the battery maybe will be penalized a little but, its worth it.

Nothing more to say.

Thanks a lot again and greetings from Argentina !

Thanks for your thanks.
I have to add one more thing. I use this tool of my own for some time now. My Desire will be 2 years old in the summer. What I still don't really understand is the following. How is that, that even the manufacturers don't see that such a solution needs to be just integrated into the system.
I still have a general standpoint that the proximity sensor SHOULD be actively used to blank/disable the touchscreen to prevent accidental touches and make the device behave unexpected WHILE the device is LOCKED by the user or itself after timing out.
About battery drain. I think this solution is better than having nothing against unwantedly keeping the screen on. If you receive a message or an event fires, the screen turns on in your pocket and you keep the screen on by making touches to it with your leg. The screen eats up your battery more than anyting.
 
Thanks for your thanks.
How is that, that even the manufacturers don't see that such a solution needs to be just integrated into the system.

I've think that this kind of solutions are not "user friendly" to the "standard user" of the most cellphones. The standard user just not worry about a lot of things....

But i agree with you.

I still have a general standpoint that the proximity sensor SHOULD be actively used to blank/disable the touchscreen to prevent accidental touches and make the device behave unexpected WHILE the device is LOCKED by the user or itself after timing out.

I agree ( again ), but even the concept of "locked" can be dificult to some users... not all the users "locks" the cellphones after the use. Just let the screen turn off. My wife is one of this kind of users with her SGS. And not all the users have access to someone to teach the concepts, and the functions on a phone.

My wife is a young wife ( 30 years old ) .. she does not lock the PC, and she does not lock the phone because does not consider that like a necesary thing.


About battery drain. I think this solution is better than having nothing against unwantedly keeping the screen on. If you receive a message or an event fires, the screen turns on in your pocket and you keep the screen on by making touches to it with your leg. The screen eats up your battery more than anyting.

My phones have a automatic lock, so, theres no posibility to keep the screen on ( no after a 15 seconds at least ) on my pocket. But, i wanna solution for the use of the power buttons, if i have a touchscreen, i want to use the touchscreen, i just dont like buttons!

The screenlock i have it with a gesture on both phones, but i need something to unlock the phone in a similar way. Your aplic its just PERFECT.

Now i dont need to touch any button on my phones.

BTW: I probe the aplic on a Milestone 2 (2.2), Milestone3 (2.3.6 ), Samsung Galaxy S, Samsung Galaxy S2 ( Ginger 2.3.6 and ICS 4.) and the aplic in all the phones works just great.

In regards of the battery drain, after two days of use i've not noticed with a penalty for the battery life.
 
can i just say that i joined this forum to tell copas 2 a big thanks,this is a brilliant app,and i have tried a few but none worked as good,not a criticism and not a problem if these apps not used but i noticed that this app doesn't work with the widgetlocker app,the proximity sensor is turned off,also would there be a way to get this to work with an app to remove the slide lock namely antilock app,it does work in a way but the proximity sensor stays active all the time without the slide lock to turn off,

once again much appreciated,
 
can i just say that i joined this forum to tell copas 2 a big thanks,this is a brilliant app,and i have tried a few but none worked as good,not a criticism and not a problem if these apps not used but i noticed that this app doesn't work with the widgetlocker app,the proximity sensor is turned off,also would there be a way to get this to work with an app to remove the slide lock namely antilock app,it does work in a way but the proximity sensor stays active all the time without the slide lock to turn off, once again much appreciated,

Thanks and sorry I don't quite understand your problem but I *am* using WidgetLocker without any problems with it :-). WidgetLocker has an option to set its own screen-off delay also, which I set to 15secs while my normal screen-off (or lock) delay is set to maximum.
 
thanks for the reply,strange i can only use your app with widgetlocker off,if i turn on widgetlocker the proximity sensor doesn't work and screen comes on,running standard android 2.3.3, weird

tried the same settings as yours and still the same
 
thanks for the reply,strange i can only use your app with widgetlocker off,if i turn on widgetlocker the proximity sensor doesn't work and screen comes on,running standard android 2.3.3, weird

tried the same settings as yours and still the same

What do you mean by 'sensor doesn't work and screen comes on'?
However it might happen because of WidgetLocker's special configuration. Check those that differ from default.
Mine comes only on when I trigger the proximity sensor. This is by so called 'design'. It means that if you send your device to sleep manually, it won't wake if something gets close. If you let it go to sleep by itself, proximity sensing remains and if you wave your hand close to the sensor, the device will wake up for some seconds you have set. I think it's a bug in Android (not in my work of course ;-) ) but it's not a big deal. One gets used to it and most important, the screen won't come up if it's in your pocket. Some people make even use of this kind of functioning. They don't use the power button at all. This can be achieved by turning 'event controlled' off.
 
I've been using this on my DroidX for a long time with great success, but I just installed it on my new Galaxy S3 with ICS and it doesn't work. If I receive a phone call with the proximity sensor covered, the screen still comes on. It also comes on when the sensor is covered and I press the power button.

I installed Smart Screen Off Lite and it works, but I prefer your app.

Any idea why it doesn't work?
 
I've been using this on my DroidX for a long time with great success, but I just installed it on my new Galaxy S3 with ICS and it doesn't work. If I receive a phone call with the proximity sensor covered, the screen still comes on. It also comes on when the sensor is covered and I press the power button.

I installed Smart Screen Off Lite and it works, but I prefer your app.

Any idea why it doesn't work?
Actually no idea. ICS has the same power management as its predecessors:
GrepCode: android.os.PowerManager (.java) - Class - Source Code View
Anyway, I'll have to check it on ICS also. My Desire's getting old now but still enjoying it. I have to make a quite huge compromise. If the S3 had a trackpad and a 4.0 inch screen, I'd already have one. I hate brick style devices and the trackpad is going to be a big loss for me whichever device i'll choose.
 
The optical trackpad is a bit of a deal breaker for me too, because it's very useful and quick to access, unlike software cursor keys.
 
THe optical trackpad is a bit of a deal breaker for me too, because it's very useful and quick to access, unlike software cursor keys.
Well, it's another thing I don't quite understand. On input fields (like a text field where there's a cursor blinking), a swipe should mean that you'd like to position the cursor to the direction you're swiping to. To sum up, a tap could mean the classic absolute positioning, a swipe could mean a relative (swipe direction based) positioning of the cursor on type input fields. There would be no need for the trackpad anymore and you could fine position your cursor. This way of course you loose the ability to scroll the whole text. Hold down a bit longer then on this type of fields to be able to scroll. Just brainstorming...

Brick style (huge) phones aren't phones either. Waiting for manufacturers to realize that.
 
proximitytoolextension AWESOME!
It's the tool i was looking for!
Thank you very much, now apps won't run in mu pocket!
I'm runing this tool under JB 4.2.2 (CM10.1 LegacyXperia Project) and it's working nicely..
 
Has anyone else tried this with a Samsung Galaxy S4 or S4 Active running Kit Kat? I have the problem described here. When I try to answer calls with a wired or bluetooth headset with the phone in my pocket, it either won't answer or answers and hangs up. I never have an issue puling the phone out of my pocket and answering it. The only thing unusual I have seen so far is the service has to be running before the headset is connected. I still can't believe the manufacturers and android developers have not fixed this. If there is a newer version or app let me know.
 
Status
Not open for further replies.
Back
Top Bottom