Unlock the Screen Programmatically

后端 未结 1 1788
终归单人心
终归单人心 2020-12-17 18:56

I have a share button in the GCM notification. On click of the share button, I need to launch share intent. Everything works perfectly. Only problem that I\'m f

相关标签:
1条回答
  • 2020-12-17 19:30

    Step 1: Add below code in your activity before setContentView(R.layout.example);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON|
                WindowManager.LayoutParams.FLAG_DISMISS_KEYGUARD|
                WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED|
                WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
    

    Step 2: Lock your mobile, then you will see activity in which you have added this code. This will work even though your mobile is locked with pattern lock. This will work like a charm.

    0 讨论(0)
提交回复
热议问题