I'm seeking information regarding the specific behavior of Android device during DOZE mode, also known as Idle mode. My app provides sensor info periodically with setExactAndAllowIdle() method. This of course doesn't work perfectly, but since the device is (or should be) static (with screen turned off and unplug from charger) I do not need the access to the sensor. My question is: if the device is stationary and in DOZE mode, does moving the device wake it up from DOZE? I've tested with adb and the answer is no, but when I tested with a device it somewhat gave the impression that moving the device actually caused it to leave DOZE mode.
I'm specifically asking about the moving action (without turning on the screen) whether it does or does not wake the device from DOZE.
Another question is:
Is there a way to programmatically tell what action woke the device from DOZE? I'm aware of PowerManager.isDeviceIdle().
Thanks in advance for your answers.
As soon as the user wakes the device by moving it, turning on the screen, or connecting a charger, the system exits Doze and all apps return to normal activity
source
So, Yes it does make wakes up by moving.
Is there a way to programmatically tell what action woke the device from DOZE?
I don't think so.
As CommonsWare have mentioned that he isn't sure about it, now I'm confident enough to simply tell you, No :)
Related
I want to test a application in idle mode. So to do that i need to wait for the device to get into idle mode which is taking 20 mins in my android device. Here idle mode means after sometime of switching of the screen, the device will get it into one mode where the cpu will goes off and the network will be disabled for the applications as mentioned here. So anybody help me to know is there any way to reduce the idle timeout using programmatic or any other way. I searched a lot. But i can't able to find anything.
When i search i found a question which is related to idle mode of application. So it is not a duplicate question.
Thanks.
If by sleep you're referring to the new doze system brought out in android 6, check out the following link which explains how you can send commands with adb to put the device into sleep mode.
https://developer.android.com/training/monitoring-device-state/doze-standby.html#testing_doze
I am aware that this question has been asked already in this site, but I could not find my answer. SO this is what i am trying ot do. My power button in my phone is not working properly. So could is there a way to override my volume up button to unlock my phone.
I am planning to implement broadcast receiver But could not find the appropriate intent-filter. Another alternative that I thought was to run a service when the screen is locked, but I am not quite sure if I can listen to key events.
So if any of the above mentioned is possible, could you hint on how to get it done or suggest another alternative?
No, It do not think so. This can not be done.
There is no broadcast for volume up or down button presently. You can implement a service that will listen for any changes in the volume but it is not recommended to run a service all the time since that consumes both battery and memory.
The only solution that I can think of is using ContentObservers for listening to the changes in the settings such as volume of streams. This answer here will provide you with the code to use ContentObserver to listen for volume up or down. https://stackoverflow.com/a/7017516/1979347
This functionality you speak of has already been done multiple times and can be found on Google Play. However, I'm not sure how they did it, or how much their solution drains the battery.
I just did a test on my G2 (Android 4.2.2), I launched a broadcast monitor, I switched to the homescreen, and I changed the volume from there.
Apparently, it can detect if the volume is turned up only when it changes from silent mode > to Vibration mode > or to Sound mode. Conversely, when pressing the down volume, I think we can detect the change when it goes from the Sound Mode > to Vibration Mode > or to Silent Mode.
This is probably not what you wanted to hear, but I just wanted to confirm what the others were saying. On a non-rooted phone, what they're saying is mostly correct. On a rooted phone however, there are custom ROMs that have solved this issue.
By the way, what brand/model is your phone? On my phone, when the headset gets connected, the phone lights up. So I suppose, one could always do it the way iPhone owners do it for their phones. You'd have to cut the extremity of a head phone jack, coat half of the pin in plastic, and super glue a button on top of it to allow you to easily twist the head.
I'm developing an app which requires the system to get the touch events even after the system goes to sleep mode or after the user locks the screen, I tried searching for a solution but it is hard to find one.
Should I want to set any permissions or is there any inbuilt methods or can I override any methods to perform this functionality.
I'm developing an app which requires the system to get the touch events even after the system goes to sleep mode or after the user locks the screen
Fortunately, this is not possible. Otherwise, the device would not be asleep, and battery life would suffer as a result.
Here is a link that shows how to prevent the phone from sleeping.
If you couple that with, say a black screen to 'pretend' the hone is sleeping but actually running your code. So your code can still intercept touch event
Then you need to install your app as a service and make it start when the device is turned on.
You will not need NDK or rooted device for that (sorry, got a short night :) )
There seems to be a lot of controversy about how to stop applications in Android, so I'll explain what I'm trying to do and why in hopes that I can receive some guidance on how to properly implement the functionality I'm looking for.
I got tired of plugging my phone into power when I get into the car, connecting the headphones, turning BT on, turning WiFi off, and then launching "Car Home" because my dock doesn't do so automatically - it's just a piece of plastic mounted to the dash.
So my application automatically does these things when I connect power - and when I disconnect power, it turns BT off and WiFi back on, but unfortunately, Car Home is still running.
I want to automate the entire process, so I never have to launch (or shut down) Car Home, and make getting in and out of the car a little less frustrating.
I know Froyo introduces ActivityManager's killBackgroundProcesses method, but this doesn't seem to work for me. It does seem to be focused around background processes, but what I've read online seems people want to use it to stop foreground applications.
I've also tried restartPackage from Eclair unsuccessfully, so I'm looking for advice.
What is the best way for me to tell the "Car Home" application to stop specifically because power is disconnected and I'm getting out of the car, without me having to navigate to it's home page and click "Exit"?
Have you seen UiModeManager?
This class provides access to the system uimode services. These services allow applications to control UI modes of the device. It provides functionality to disable the car mode and it gives access to the night mode settings.
I have a service that will be started every once in a while via an AlarmManager.
When it starts I want to be able to check if the device is currently being used or if it is idle.
I could simply check if the screen is on, but it is possible that if the device was charging, or on a dock, that the screen could be on but not being used. So that is is not a perfect method.
Is there a solid way determine that the device is idle?
If not, I figure if the device is plugged in, then in my case I could just carry on as if the device was idle. However, I haven't been able to find a way to check if the phone is plugged in beyond capturing a Broadcast Intent. Is there a way to just check without having to capture the broadcast intents continually?
Android has an in built application called Autolock that can be customized.Please refer these links.
http://www.androidtapp.com/autolock/
http://developer.android.com/guide/practices/design/responsiveness.html
Hope this will help you.