2016-07-18 10 views
0

나는 GCM을 사용하는 응용 프로그램과 함께 작업하고 있습니다. 그래서 잠시 후 화면을 잠그면 전화기가 수면 모드이됩니다. 그 전화로 메시지를 보내려고하지만 배달 할 수는 없지만 화면을 켜면 즉시 메시지가 배달됩니다. 그래서 너희들은 내가 잠자기 모드로 올 때라도 전화를 깨우도록 도와 줄 수 있을까? (나는 그렇게 생각한다).슬립 모드에서도 안드로이드 깨우기

P/s : 이미 내 프로젝트에 WAKE_LOCK 권한이 있습니다.

답변

0

이렇게하면 화면을 깨울 수 있습니다. 는 깨우려면 :

보호 무효 웨이크 업() {

//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"); 

} 
+0

이 작동하지 않을 것, 감사 –

+0

이 코드 도움이 그냥 깨워 그 후에 당신은 당신이 할 수 App.Can 열기 위해 사용자의 함수를 호출 할 수 있습니다 특정 오류가 무엇입니까. –

+0

전화기를 몇 분 동안 잠궈두면 CPU 모드가 해제됩니다. 이 모드에서는 더 이상 위의 방법을 사용할 수 있습니다. –