Please help me. I have a broadcast receiver:
public class BrcRec extends BroadcastReceiver{
public static WakeLock wakeLock;
@Override
public void onReceive(Context context, Intent intent) {
PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
wakeLock.acquire();
KeyguardManager keyguardManager = (KeyguardManager) context.getSystemService(Context.KEYGUARD_SERVICE);
KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG");
keyguardLock.disableKeyguard();
Bundle extras = intent.getExtras();
StringBuilder msgStr = new StringBuilder();
msgStr.append(" : ");
Format formatter = new SimpleDateFormat("hh:mm:ss a");
msgStr.append(formatter.format(new Date()));
Toast.makeText(context, msgStr, Toast.LENGTH_LONG).show();
wakeLock.release();
}
And then it works, my android does not wake up: the button blinks once, and that’s all. Where is the mistake?
I want to wake up android and cause some activity as a result. Thank.
source
share