Keep the background with wakelock Android lock screen state awaken but
@ Override
Protected void onPause () {
Super. OnPause ();
//handler. PostDelayed (bluetooth, TIME).//4 minutes to perform a
ReleaseWakeLock ();
}
//release equipment power lock
Private void releaseWakeLock () {
if (null !=wakeLock & amp; & WakeLock. IsHeld ()) {
The Log. I (" WakeLock ", "call releaseWakeLock");
WakeLock. Release ();
WakeLock=null;
}
}
@ Override
Protected void onResume () {
Super. OnResume ();
AcquireWakeLock ();
}
/* ** access to the power lock, keep this service in screen dies still get CPU, keep running
*/
Private void acquireWakeLock () {
If (null==wakeLock) {
PowerManager PM=(PowerManager) getSystemService (Context. POWER_SERVICE);
WakeLock=PM. NewWakeLock (PowerManager. PARTIAL_WAKE_LOCK
| PowerManager. ON_AFTER_RELEASE getClass ()
GetCanonicalName ());
if (null ! WakeLock)={
The Log. I (" WakeLock ", "call acquireWakeLock");
WakeLock. Acquire ();
}
}
}
CodePudding user response:
System version 6.0.1 EMUI4.0.3 systemGlory eight EMUI5.0.1 system (7.0) on the test no task
CodePudding user response:
Use the method of 1 pixel keep alive also didn't workhttps://www.jianshu.com/p/ef4a9531bc15
CodePudding user response:
Thinking: AlarmManager used alarm clock timing to send radio cooperate PowerManager CPU is not sleep, receives the broadcast awaken and unlock the screen, and then in the drawbacks of the method of using lock screen when screen is flashing, but all the services, radio work,CodePudding user response:
Cordova development also encounter this problemI solved the
CodePudding user response:
Add white list and dormancy is prohibitedCodePudding user response:
The