-1

i have a problem in my android torch that i just created with android studio i have finish building this torchlight and i have run and install it in android phone but there is on problem i will like you to help me to solve it out.

  1. if i On the torch light it will On but if the screen of the android phone when off, the torch light Off too. and if i touch the phone screen and the screen light shows the torch will On. why please i need to make the torch light to be On even when the phone is lock and unlock and even when the screen light is On or Off . please help me out.

thanks.

Tugadar
  • 1
  • 3
  • try this answer: http://stackoverflow.com/a/25745421/944734 – xklakoux Jun 07 '16 at 17:44
  • 1
    If the linked comment answer does not help you, you will need to paste at least some key bits of your code in your question in order to help others answer it. it is generally impossible to give quality answers to code questions without any code to inspect. – Creos Jun 25 '16 at 13:39

1 Answers1

0

Running Apps and services are pause when the phone is locked, but you can acquire WAKE_LOCK key and do your task

PowerManager mgr = (PowerManager)context.getSystemService(Context.POWER_SERVICE);
WakeLock wakeLock = mgr.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK,"MyWakeLock"); 
wakeLock.acquire();

this will hold the CPU open even if the screen off

Vishwesh Jainkuniya
  • 2,821
  • 3
  • 18
  • 35