2

I want to capture image when home screen is off/locked. And I have used this line of code and works properly up to lollipop. But it doesn't do anymore in Marshmallow. I have also tried to "disable optimize". Please help me.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
    setContentView(R.layout.activity_camera);
    PowerManager pm=(PowerManager)getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock=pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,TAGg);

    wakeLock.acquire();

    // do something here..........

}
ankuranurag2
  • 2,300
  • 15
  • 30
Getaw Dejen
  • 341
  • 1
  • 4
  • 13

0 Answers0