0

I working with application that using GCM. So when I lock my screen and few minute after that, maybe the phone come to sleep mode. I try to send message to that phone but it cannot deliver, but when I turn screen on, the message delivered immediately. So could you guys help me to wake up phone even it come to sleep mode (I guess so).

P/s: I have WAKE_LOCK permission on my project already.

Bui Quang Huy
  • 1,784
  • 2
  • 17
  • 50

1 Answers1

0

You can wake your screen by using this. To wake:

protected void wakeUp(){

        //to wake the screen

        PowerManager pm = (PowerManager) getApplicationContext().getSystemService(Context.POWER_SERVICE);
        PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
        wakeLock.acquire();
        //to release the screen lock
        KeyguardManager keyguardManager = (KeyguardManager) getApplicationContext().getSystemService(Context.KEYGUARD_SERVICE);
        KeyguardManager.KeyguardLock keyguardLock = keyguardManager.newKeyguardLock("TAG");
        //add permission in the manifest file for the disablekeyguard
        keyguardLock.disableKeyguard();
        // Intent intent=new Intent("android.intent.category.LAUNCHER");
        //Intent.setClassName("com.samsung.android.sdk.accessory.example.helloaccessory.provider", "com.samsung.android.sdk.accessory.example.helloaccessory.provider.Main3Activity");
       
    }
Nishant Rajput
  • 2,053
  • 16
  • 28
  • this code help to just wake up and after that you can call your function for opening App.Can you be specific whats the error. – Anuj Sharma Jul 18 '16 at 06:56
  • After you let your phone lock screen few minutes, it will turn into CPU mode off. in this mode we can use that method above anymore. – Bui Quang Huy Jul 18 '16 at 07:18