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

by MrChaz » Tue, 13 Apr 2010 17:16:57 GMT


Sponsored Links
 iirc, that flag means the system gets a wake lock for the life of the
activity for you.




--



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

by westmeadboy » Tue, 13 Apr 2010 17:19:20 GMT


 Oh I see.

So if the user presses Home and then uses the power button, then it
*could* fall asleep (in the case where the activity has been killed by
the system)?





--


Sponsored Links


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

by westmeadboy » Wed, 14 Apr 2010 15:45:23 GMT


 Just to confirm: the device is not plugged into USB and I'm not using
any broadcasts or broadcast receivers.

When I do plug in and start the service these are the wake locks:

mLocks.size=3:
  SCREEN_DIM_WAKE_LOCK           'StayOnWhilePluggedIn Screen Dim'
activated (minState=1)
  PARTIAL_WAKE_LOCK              'StayOnWhilePluggedIn Partial'
activated (minState=0)
  SCREEN_BRIGHT_WAKE_LOCK        'KEEP_SCREEN_ON_FLAG' activated
(minState=3)

and then when I homescreen, other app, turn the screen off (as
describe above) but leave the device plugged in, the third one
disappears.

So I would assume that when I unplug the USB, the first two to
disappear also...







> >



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

by THill » Fri, 23 Apr 2010 03:51:12 GMT


 hanks Dianne, that makes sense.

I didn't realize there was essentially one wake lock that the kernel &
applications layer use, so when all apps give up the wake lock, they
will still get awaken when the cpu wakes to handle kernel processes.

This explains why the 1-second timer pops occurred at 1 second
intervals before & after the sleep, and at very erratic intervals
during the sleep.

I saw the same behavior on a similar test case with an AsyncTask
sending messages through a handler to the UI. Neither the task, nor
the handler, was completely frozen during the sleep, but the task was
taking longer to complete during that time.

Unfortunately, my production app has specific power usage constraints
imposed by the manufacturer/carrier (especially with the device
asleep), and it doesn't seem there is a good way to make sure the app
completely goes dormant when the device sleeps. Any suggestions are
welcome.

Cheers
Tim

On Apr 22, 10:58am, Dianne Hackborn <hack...@android.com> wrote:
> >



Other Threads

1. Menu Force Close Issues

Hi, I'm having some troubles with the menu I just added to my app.

I'm using a basic

Java:
   @Override
    public boolean onCreateOptionsMenu(Menu menu)
    {
      super.onCreateOptionsMenu(menu);

      MenuItem item = menu.add(0,1,0,"Bookmark");
      item = menu.add(0,2,0,"Remove Bookmark");
          return true;
 }


to create my menu, and a

Java:
      public boolean onOptionsItemSelected(MenuItem item)
       {

        if(item.getItemId()==1){
.....


to make it do things. Now the trouble is, occasionally, when i start
my app up for the first time, or do a fresh install when testing it,
and i click the menu button, it's gives me a force close error. It
only seems to do it the first time on the very first screen. If i
click either of my other buttons that refresh the view it tends not to
do it, or, if you get it to open up and work once, it tends to be
stable after that...

It's driving me a bit crazy though, cause I can't see anything obvious
wrong with my code, or why it would want to crash on a simple thing
such as the menu screen...

This is what logcat throws up when the app crashes, but it doesn't
mean a whole lot to me yet...

Quote:
07-16 18:11:42.721: ERROR/AndroidRuntime(21831): Uncaught handler:
thread main exiting due to uncaught exception
07-16 18:11:42.991: ERROR/AndroidRuntime(21831):
android.view.InflateException: Binary XML file line #17: Error
inflating class java.lang.reflect.Constructor
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.LayoutInflater.createView(LayoutInflater.java:512)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:
564)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.LayoutInflater.inflate(LayoutInflater.java:385)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.view.menu.MenuBuilder$MenuType.getMenuView
(MenuBuilder.java:196)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.view.menu.MenuBuilder.getMenuView
(MenuBuilder.java:322)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.policy.impl.PhoneWindow.initializePanelContent
(PhoneWindow.java:930)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.policy.impl.PhoneWindow.openPanel
(PhoneWindow.java:528)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.policy.impl.PhoneWindow.onKeyUpPanel
(PhoneWindow.java:693)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.policy.impl.PhoneWindow.onKeyUp(PhoneWindow.java:
1367)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.policy.impl.PhoneWindow$DecorView.dispatchKeyEvent
(PhoneWindow.java:1684)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.ViewRoot.deliverKeyEventToViewHierarchy(ViewRoot.java:
2188)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.ViewRoot.handleFinishedEvent(ViewRoot.java:2158)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.ViewRoot.handleMessage(ViewRoot.java:1490)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.os.Handler.dispatchMessage(Handler.java:99)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.os.Looper.loop(Looper.java:123)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.app.ActivityThread.main(ActivityThread.java:3948)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
java.lang.reflect.Method.invokeNative(Native Method)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
java.lang.reflect.Method.invoke(Method.java:521)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run
(ZygoteInit.java:782)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:540)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
dalvik.system.NativeStart.main(Native Method)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): Caused by:
java.lang.reflect.InvocationTargetException
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
com.android.internal.view.menu.IconMenuView.<init>(IconMenuView.java:
140)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
java.lang.reflect.Constructor.constructNative(Native Method)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
java.lang.reflect.Constructor.newInstance(Constructor.java:446)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.view.LayoutInflater.createView(LayoutInflater.java:499)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): ... 21 more
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): Caused by:
java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:363)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:212)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.graphics.drawable.Drawable.createFromResourceStream
(Drawable.java:663)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.content.res.Resources.loadDrawable(Resources.java:1637)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): at
android.content.res.TypedArray.getDrawable(TypedArray.java:548)
07-16 18:11:42.991: ERROR/AndroidRuntime(21831): ... 25 more


I'm running this direct on my device through the usb, but it also
crashes the emulator too.

any ideas?

Thanks
--~--~---------~--~----~------------~-------~--~----~

2. Debug Native JNI code on Android emulator

Hi!

I'm trying to debug my native JNI code located on a shared library.
I have been trying to debug using gdb/gdbserver.

Here is how I go about, trying to debug:

I need help how to debug JNI native code
on the Android emulator
I'm using gdb/gdbserver
I do this at the emulator terminal
gdbserver localhost:1234 --attach 737
Attached; pid = 737
Listening on port 1234
Remote debugging from host 10.0.2.2
on the client PC I do this:
arm-eabi-gdb libtestJNI.so
(gdb) set solib-search-path /system/lib
(gdb) info threads
  1 Thread 737  JNI_OnLoad (vm=0xafe0af93, reserved=0x0) at
testJNI.cpp:15
(gdb) thread 1
[Switching to thread 1 (Thread 737)]#0  JNI_OnLoad (vm=0xafe0af93,
reserved=0x0) at testJNI.cpp:15
15 jint JNI_OnLoad(JavaVM* vm, void* reserved)
(gdb) b Java_testJNI_printHello
Breakpoint 1 at 0xafe0d54c: file testJNI.cpp, line 53.
(gdb) c
Continuing.
... when I step on the Android Java code so the function
Java_testJNI_printHello is called, I get this error on the server side
gdb: Unable to get location for thread creation breakpoint: requested
event is not supported

please help??

Thanks

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

3. Communication API/mechanism to talk between emulator<->desktop?

4. Method for flashing a device HTC G1 dev edition

5. WYSIWYG Designer -> PMF

6. WYSIWYG Designer

7. How data storage security work