0

I am react native developer, actually I have an app which I am running in background what I want to achieve if app is running in foreground or background I want to prevent screen from auto lock . For that purpose I found one library expo-keep-awake which awake user screen when app is running in foreground but this library is not working if app is running in background so I have decided to do code in android if app is running in background so I want to prevent auto screen lock . I am not android developer could someone please help me how to resolve this issue .

Thanks

JonasDev
  • 67
  • 1
  • 8
  • why do you actually need device be awake? Why not just use Service that run un background? – borichellow Sep 18 '20 at 18:46
  • @borichellow actually react native does not fully support background service . I have requirement if app is running in background then I am gonna send coords continuously. for that purpose I need to prevent auto lock if app is running in background – JonasDev Sep 18 '20 at 18:47
  • try to use `Service` with `startForeground`. Here is an example https://www.tutorialspoint.com/how-to-implementing-start-foreground-for-a-service – borichellow Sep 18 '20 at 18:55

1 Answers1

0

It sounds like you need to try AsyncTask and take a look at DoInBackground, try this link it may help: AsyncTask Android example

Android developer Docs: https://developer.android.com/reference/android/os/AsyncTask

  • Kindly add context to any links so your answer is self contained, meaning the answer needs to be here in the Answer itself. See ["Provide context for links"](https://stackoverflow.com/help/how-to-answer). Unless you think this is a duplicate Question, and you'll be able to flag it as such at 15 [reputation](https://stackoverflow.com/help/whats-reputation) points. – Scratte Sep 19 '20 at 10:08