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. Streaming MP3 from HTTP using MediaPlayer

Hi,

I'm trying to stream MP3 audio file from HTTP by using MediaPlayer class. I
found only few of MP3 files could be played. Most of them cannot stream.
MediaPlayer will go into Error state while trying to play.

Here's my code:

mp.reset();
try {
mp.setDataSource(this, src_uri);
} catch (Exception e) {
mp.release();
FeUtil.showToast(this, "Can not play: " + src_uri.getPath());
return;
}
mp.setOnCompletionListener(this);
mp.setOnErrorListener(this);
mp.setOnPreparedListener(this);
mp.setAudioStreamType(AudioManager.STREAM_MUSIC);
mp.prepareAsync();

@Override
public void onPrepared(MediaPlayer mp) {
mp.start();
}


I found that on Android 1.6/2.1, the default system media player app also
cannot play those MP3 files from HTTP just like what I met here, but on
Froyo the default system media player app can play all MP3 files from HTTP.

So does anyone know how to stream MP3 from HTTP?

Thanks a lot!

Alex

-- 

2. App Signing & Testing and Publishing Options

I am about to write an App which is customized to Macau, a city in
Southern China. I am experiencing some uncertainties and would like to
seek help from the fellow developers.

I have checked with Android Dev Guide and found out that we have gotta
sign the App with self-generated key or a digital certificate issued
from Certificate Authority. May I know whether there are any
differences in the user experience when downloading and using the App
for self-generated key or digital cert from CA? I heard that Symbian
Apps would display alert message like "This App is untrusted" if the
App is not formally verified. I do not want this to happen in my App,
and I am worried about other tiny differences.

Moreover, I would like to ask about the requirements for digital
certificate for signing the App. Is there any specification? Must the
key be a .keystore file for signing? I am thinking about applying one
from the Post Office for signing, but am worried whether it works.

to the computer using USB and run the App and perform testing using
the computer. May I know more about the testing procedures from the
experienced? After this debugging process how can I test the App on a
standalone Android phone just like using the App normally? Can I
simply sign the App with debug key in the debug mode and use it on the
device? Must the device be developer device or Nexus One for
performing testing?

If I publish the App to the Web server, i.e. users can download the
file and use my file, would my source code be leaked out and get
accessed by other people?

Last but not least, as I am developing the free App in Macau, I was
stuck when I saw that Macau is not on the developer location list. I
wonder whether I can publish my App on the Android Market. When I
settle the Google Checkout payment, which option should I choose as my
location, as neither China nor Macau is on the list. Should I choose
"Hong Kong", my neighbouring city, or simply click "US" for
convenience? Can the Android users in Macau download my App from the
Android Market? (I cannot see Macau on the supported distribution
location list...)

I would really appreciate it if you could kindly answer my loads of
questions. Thank you very much!

-- 

3. Gingerbread on the Nexus One

4. GNU Make 3.82 raises "make: free(): invalid next size (fast)" error when building AOSP

5. Developing Phone

6. Suddenly errors being reported

7. Custom control redraw