In Google documentation about ACTION_SCREEN_OFF they write:
This broadcast is sent when the device becomes non-interactive which may have nothing to do with the screen turning off. To determine the actual state of the screen, use Display.getState().
So I asking when the screen becomes non-interactive and it still turned on.
When you press the power button to lock the screen (or even if the device's screen lights get off, due to inactivity), at that time it goes to a non-interactive state.
And yes, the device will be turned on.
Related
My android app is able to run on the bakground and I'd like it to do so wenever the user stops interacting with the phone.
I the app is open and the user does nothing with it for x time, I expected Android to lock the screen (which is what i want).
However, the app simply keep th screen on. Why?
I do not use android:keepScreenOn="true" anywhere on the app.
Are you acquiring a WakeLock ?
If yes you should use PARTIAL_WAKE_LOCK instead FULL_WAKE_LOCK or SCREEN_BRIGHT_WAKE_LOCK the first lets the screen go off, the others don't
Well, turns out it was my fault, not the apps.
I had enabled 'Keep screen awake while charging', and since I had the phone connected to the computer, the screen never locked...
I'll leave this here in case someone else is in the same situation.
I have a service that detects when the display of my Android phone is turned on or off. When turned off, the service calls an activity that uses dispatchKeyEvent to detect when the volume up button has been pressed. Unfortunately, apparently the activity can't do this when the screen is off. (See this post.)
I've noticed, though, that something at some level is detecting that event, since the following LogCat message appears when I press the volume-up button when the screen is off: "CatService: Return current sInstance". The message seems to be device specific, since on a different device something different appears in the log, but I'm really only concerned about the first device.
I've done some research into CatService, but haven't found much and can't figure out how I might be able to use it, or whatever is generating the log message, to detect the volume up button press. I'd appreciate any light that anyone can shed on this.
The only way to keep detecting things like this when the screen is off is to acquire a WakeLock that will allow the screen to turn off, and still let your app function. However, this drains the battery life quite a bit, and should only be used when absolutely necessary.
In this case, you will need a PARTIAL_WAKE_LOCK.
I want to get an android device to wake up from sleep or however the state in which the phone gets after a certain amount of inactivity when the screen goes dark, by detecting a touch to the screen instead of clicking on any button.
In the documentation the only thing I have found is the FLAG_TOUCHABLE_WHEN_WAKING flag in WindowManager.LayoutParams and it says:
Window flag: When set, if the device is asleep when the touch screen
is pressed, you will receive this
first touch event. Usually the first
touch event is consumed by the system
since the user can not see what they
are pressing on.
I thought that meant that if the device's screen is turned off and that flag is set for an Activity then it will wake up to the touch (which is what I want it to do). Am I misunderstanding the purpose of this flag? Are there additional implementation details I'm ignoring? Is there some other way?
Am I misunderstanding the purpose of this flag?
AFAIK, yes. There is a slice of time between when the screen turns off and when the device falls asleep. During this time, if the user touches the screen someplace where the window has this flag, the screen turns on again and the inactivity timer is reset.
I can find no other use of this flag in the Android source code.
Is there some other way?
No. If the device is asleep, touch screen events are not registered.
i'm making a program that disables your wifi when you lock your screen
but i can't find an object the holds that kind of information (wether it's locked or not)
In most Android phones Wifi is turned off a few minutes after the screen is locked.
This setting can also be controlled by the user in Settings->Wireless Netowrks->WiFi->Advanced.
Anyway, if you want to tell when the screen is locked, register to receive the ACTION_SCREEN_OFF broadcast intent.
My application requires resource and drains a battery when it is working. So, I want to know the way that user is not available on the phone.
Is there a way to use the built in power save mode on the blackberry to where if the screen dims to suspend the application works active and when the user wakes the device back up with a keypress or trackball movement to resume the application works active?
Thanks in advance.
Is there a way to use the built in
power save mode on the blackberry to
where if the screen dims to suspend
the application works active and when
the user wakes the device back up with
a keypress or trackball movement to
resume the application works active?
This happens automatically, with no code changes required. Unless something is holding a WakeLock, the CPU will turn off sometime after the screen goes dark. The CPU will turn back on when the user presses the power button.