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
Related
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 :)
Can you programmatically check to determine if your android device is in deep sleep mode?
Reason being, if it is, you may obtain a wake lock or a wifi lock... however, is it is not, you wouldn't want to obtain a wifi lock if it is not necessary. Since, I also have a delay created when a wifi lock is obtained in order to allow the device time to connect to the network. If it is not needed, I do not want to get the wifi lock and add a delay.
I got a suggestion for you,
Register to screen off and on, when screen off take a one minute timer, if screen on cancel it, when you got to end of timer do your locks, till screen on again.
My App sends out GPS data with a timer. Sometimes I block the screen.
Now with some phones and only sometimes I have the problem that the OS somehow blocks the data packages and only releases them later, when the screen is unlocked. The messages still are getting sent from the app but only stopped in android.
Anybody have a Idea why that happens and how I can stop it?
Is it possible that those devices are going to sleep (or sending the radio to sleep)? Have you tried setting a wakelock to prevent this? https://developer.android.com/reference/android/os/PowerManager.WakeLock.html
I suspect your application goes to sleep, or your wifi. There are applications specifically designed to keep your wifi alive, so i suspect it does sleep. Were i to create the wifi, i would definitely make it sleep when there wasnt anything to say.
To test download one of the apps. That and write to a log file when your application is going to sleep.
Sorry i couldnt give a specific answer. Id have posted this as a comment, but im too new to be able to do that.
i have coded my 2nd android application that switches audio profiles based on a certain schedule (date and time only as of now)....the code is working without any issues if i run the code using the emulator via eclipse...however i recently exported the apk and installed it on my At&t Samsung Galaxy S2 and added the same profile schedule as the emulator, but for some odd reason the timertask is not executing after the 1st time...
For Example:
Here is the Profile Schedule from my phone as well as the emulator:
8AM - 5:30PM -- Work
5:30PM - 10PM -- Home
10PM - 8AM -- Sleep
once the above is scheduled and i press the activate button on the main activity..a background service runs switching from one profile to the next until it is de-activated...
the only difference i have noticed between the emulator and my phone is that, the emulator screen never shuts off...so im guessing that the emulator doesnt ever go on sleep? whereas, my phone's screen turns off after about 30 seconds of inactivity, in addition to the lock screen...furthermore, i turned on USB debugging on the phone and plugged it directly into the computer and from what it seemed like, the code was executing, switching one profile to the next, on my phone without any issues...(Note that, when i was doing this testing, i used smaller time intervals in the profile schedules)...Additional details: i have also added startForeground() in my service code and ensured that the service is not getting terminated...
does anyone have any idea on what im missing, or what i can do to get around this bizarre problem?...i did do some research before posting this, and found out few posts that recommended using: Android's PowerManager...
Thanks for your input
Nothing weird about this: if the phone is asleep, the CPU is off and you cannot execute code. Don't use TimerTask on Android, use AlarmManager to schedule recurring tasks. It's implemented in the kernel and can wake up the phone if necessary (that might have a negative impact on battery life, so use with caution). Also look into WakeLock's.
http://developer.android.com/reference/android/app/AlarmManager.html
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 :) )