Not using a WakeLock so why does the device stay awake?

by Mark Murphy » Tue, 13 Apr 2010 19:50:26 GMT


Sponsored Links
 


If you eliminate your parenthetical expression, then yes. The activity
being killed/not-killed has no impact -- the flag only affects the
device when the activity is in the foreground.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

Android Online Training: 10-14 May 2010:  http://onlc.com 

--



Not using a WakeLock so why does the device stay awake?

by Mark Murphy » Wed, 14 Apr 2010 19:31:52 GMT


 


You aren't, but unless you have a completely clean device (or have
hammered stuff into submission with a task killer), there might be other
apps using alarms.


Make sure your screen timeout setting is set to a low value (yes, I
know, you're manually turning off the screen, but humor me for a bit).

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 3.0
Available!

--


Sponsored Links


Not using a WakeLock so why does the device stay awake?

by Mark Murphy » Fri, 23 Apr 2010 04:07:54 GMT


 


I'd start by using AlarmManager without a _WAKEUP style alarm, instead
of having some Timer going. This would let you get rid of your process
from memory.

Those alarms will still get fired "the next time the device wakes up",
and I'm not sure if that's just the CPU being on or if that waits until
the screen is on.

If that is still too frequent, then you can watch for ACTION_SCREEN_OFF
and ACTION_SCREEN_ON broadcasts and disable/enable your alarms on that
condition. Unfortunately, I think those can only be caught via a
BroadcastReceiver registered via registerReceiver(), which brings you
back to having a service in memory all the time.

If the device you are running is going to be Android 2.1 or higher, you
have another option: isScreenOn() on PowerManager. Check that on your
alarms and use it to tune your alarm frequency back to as slow as you
can stand, bearing in mind that you won't know if the screen turns back
on until the next alarm.

-- 
Mark Murphy (a Commons Guy)
 http://commonsware.com  |  http://twitter.com/commonsguy 

_The Busy Coder's Guide to Android Development_ Version 3.0
Available!

--



Other Threads

1. WakeLock finalized while still held?

For the experts listening...

I have a background service running and I sometimes, but not always,
receive the following error when clicking on a notification, which
opens the main App activity.

WakeLock finalized while still held

In my search for an answer, I read the post below:

http://www.mail-archive.com/android-beginn...@googlegroups.com/msg16051.html

While it appears to make sense technically, it doesn't work for this
app.  Like scanning for voicemail, this background service needs to
constantly, and forever, stay alert - checking the server every few
minutes for notifications.

So my questions are:

1.) Why is GC coming after my WakeLock (or is after my service?), just
b/c someone clicked on a notification it launched?

2.) Can I prevent GC from messing w/ my PowerManager object and my
service?

3.) is there a way to have the service running indefinitely w/ an
indefinite WakeLock?

I understand the answer, if there is a sutiable one, probably doesn't
fit most apps out there.  For that reason, it may not even make sense
to provide the answer, since every user from here on out will be able
to find it and leave their services running indefinitely.  But I need
to, so please email me privately if you can.

-- 

2. question about search suggestion rating

Hi All,

I am reading the source code that are related to search function. I can't
find the algorithm about the rating of the search suggestion, does anyone
can give me a hand?

Thanks a lot,

James

-- 

3. Paging boss leonardus jeff

4. Using onRetainNonConfigurationInstance to keep Media player after orientation change

5. About applying theme over application wide

6. Can we move a window using movement keys?

7. Problem with decodeByteArra