Able to develop a mobile phone application to wake from sleep, using wakelock realize, java code is as follows:
mWakeLock = mPowerManager.newWakeLoc (PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, getClass () getName ().);
mWakeLock.acquire ();
When phone charger or computer USB port to connect the debugger, you can wake up the phone; But once out of the computer or not charging, you can not wake up the phone .
We know why, any suggestions?<-! Main posts under Banner (D4) -><-! Posts under the main text (D5) ->
Reply:
Because the phone while it is charging does not suspend
Try to use the alarm to wake up by
Reply:
When connecting a USB charging, the phone does not go to sleep. PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP in time to keep the screen lit bright state, if the user presses the power button to put out the screen, in the absence of a USB connection, the phone will still sleep.
After PowerManager.PARTIAL_WAKE_LOCK can be done manually extinguished screen, CPU still does not sleep. But after 15 minutes, if the system detects that your application has not held a WakeLock release, the process will be forced to shut down your system then it goes to sleep it. Related code You can look at frameworks / base / services / java / com / android / server / am / ActivityManagerService.java Lane checkExcessivePowerUsageLocked () method.
Reply:
Reply:
Obviously, it is not inserted into the usb into deepsleep's.
After unplug the usb, entered the deepsleep, your program can not be run (is suspended), it is impossible to be able to light up the screen.
The correct approach is to play an alarm, use alarmmanager it can be modeled on the alarm clock.
Reply:
guoyoulei520 and shadow_dance right.
You can wake up with a phone alarmmanager, or do not always hold PARTIAL_WAKE_LOCK release
No comments:
Post a Comment