Unlock the Screen Programmatically

落花浮王杯 提交于 2019-11-29 06:39:52
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 than 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. 
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!