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. startActivityForResult problem...

I have an activity that needs to start another activity in the
onCreate method.  The second activity doesn't have a UI, it just
processes some data (very quickly) and returns it via setResult.

The problem I am having is that it looks like the onActivityResult
method from my first activity is called before the second activity has
finished!

I put in some Toast notifications to be sure, but the order that the
notifications appear is as follows:
- onCreate for Activity1 (just before calling startActivityForResult
to launch Activity2)
- onActivityResult for Activity1
- onCreate for Activity2

Has anyone else run into this problem?  I have not been able to find
anything about this issue on these forums or on google.

Thanks in advance,
Justin
--~--~---------~--~----~------------~-------~--~----~

2. wrap around with textview in a tablelayout broken

Hi Fabian,
Actually, your TextView is just fine; all the text "exists" and is wrapping
properly, it has just been rendered off the edge of the screen. It is the
TableLayout that is doing something odd.

(In fact, I found that if I put items following the TableLayout, but still
within the vertical LinearLayout, they don't show, presumably pushed
offscreen right....)

If you leave out the TableLayout, you will find that the TextView is
functioning properly. Perhaps you can use something other than TableLayout
for your app. Here is a working example:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="horizontal"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >
   <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
       android:text="Title:"
   />
   <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="Ein ganz langer Text der umgebrochen werden muss, der
so lange ist, dass er auf mindestens 3 zeilen verteilt werden muss"
  />
</LinearLayout>



And here is a puzzling non-working example where the textViews were
duplicated just after the TableLayout....

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
   android:orientation="vertical"
   android:layout_width="fill_parent"
   android:layout_height="fill_parent"
   >
   <TableLayout
       android:layout_width="fill_parent"
       android:layout_height="fill_parent"
   >
       <TableRow>
           <TextView
               android:text="Title:"
           />
           <TextView
               android:layout_width="wrap_content"
               android:layout_height="wrap_content"
               android:text="Ein ganz langer Text der umgebrochen werden
muss, der so lange ist, dass er auf mindestens 3 zeilen verteilt werden
muss"
          />
       </TableRow>
   </TableLayout>

   <TextView
   android:layout_width="wrap_content"
   android:layout_height="wrap_content"
       android:text="Title:"
   />
   <TextView
       android:layout_width="wrap_content"
       android:layout_height="wrap_content"
       android:text="Ein ganz langer Text der umgebrochen werden muss, der
so lange ist, dass er auf mindestens 3 zeilen verteilt werden muss"
  />

</LinearLayout>









--~--~---------~--~----~------------~-------~--~----~

3. Can we take pictures without setting a camera preview?

4. Can i fetch the latest image from gallery taken from camera ?

5. Convince Dalvik to add a class with the same canonical path as another

6. connect to wifi from Program

7. Can i install 'barcode scanning app' on emulator ???