proximity value

Post your questions and help other users.

Moderator: Martin

Post Reply
dudi13
Posts: 5
Joined: 07 Aug 2013 21:31

proximity value

Post by dudi13 » 08 Aug 2013 07:27

Hello and thanks For your app.

when I try to use proximity sensor, I get only 5 or 0 When there is a change. and its ok.
but sometime I get error value like 0.xxxxxx or 1.xxxxxx.
I don't think its my phone. because it works 100% to blank screen during a call.

Another question
How best to use the proximity sensor to cut the battery use?
Do use as trigger, or as a condition that I check every 2 seconds?

thanks

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: proximity value

Post by MURTUMA » 08 Aug 2013 07:44

It's a bug in android, when proximity sensor can't get a value(i.e.the distance is too big) it returns an error message. You can circumvent this in automagic using exception line when you want to check if proximity value is high. With that you can continue executing your flow without an error message.

dudi13
Posts: 5
Joined: 07 Aug 2013 21:31

Re: proximity value

Post by dudi13 » 08 Aug 2013 07:58

MURTUMA wrote:It's a bug in android, when proximity sensor can't get a value(i.e.the distance is too big) it returns an error message. You can circumvent this in automagic using exception line when you want to check if proximity value is high. With that you can continue executing your flow without an error message.
Thanks

The problem is not error message.
The problem is that I have only two values ​​0 and 5 near to far, received only during change in proximity.
when Resulting in a value of error it remained until the next change. Then I do not know whether to open or close the speaker.

On the other hand there is no such problem for "auto speaker" application or to screen blackouts when closer to the ear, to work 100%.

(galaxy advance)

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: proximity value

Post by MURTUMA » 08 Aug 2013 08:40

That's because of inaccuracy of said sensor. Use 0 or 1 for low values and from 1 to 3 or exception line for high values. Tweak the values so you find combination which works in your phone best.

Basically you can't measure proximity with that sensor due to its inaccuracy. You can use it only as on or off switch.

dudi13
Posts: 5
Joined: 07 Aug 2013 21:31

Re: proximity value

Post by dudi13 » 08 Aug 2013 11:23

Thanks Murtuma

I did not write clearly.
My problem is:
Say I want to turn off the speaker when it is close and turn on when it is far.
When I get a 0 or 5 the program know if it is near or far. But when the value 1.xxxxxxx I do not know if it is near or far (the Error value can appear in near or far).
Further examination of the condition in the program does not help that, the value changes only when change in the physical proximity to sensor.

I thought about the possibility of doing in a state of exception "togel change" compared to what it was before. But it's a little crooked.

Thanks

User avatar
MURTUMA
Posts: 697
Joined: 05 Mar 2013 22:43

Re: proximity value

Post by MURTUMA » 08 Aug 2013 12:00

For me the error only happens when value is too high(as in far). Put the exception-line on the same route, where you put the far-line. Although if you get the error also with low values, that doesn't help. If that's the case, then I can't help you any further.

Post Reply