0

I want to use this line:

getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);

But Delphi 10 does not understand this code. Did I forget to put a command in the uses clause?

I tried:

FMX.Platform.Android, Androidapi.helpers,
Androidapi.JNI.GraphicsContentViewText,  
Android.Provider.Setting.System, FMX.Helpers.Android

But none of them resolves my problem.

Can anyone help me with this problem?

  • 1
    Same question: [Wanting to keep the screen on in Delphi app on Android](http://stackoverflow.com/q/34802583/576719). Use the `WakeLock` method instead. – LU RD Oct 19 '16 at 13:07
  • yes i want to reply on that question, but my post was deleted, i've tried this but not succeed. – Ronaldinho Oct 19 '16 at 15:19
  • If you tried to use the WakeLock method, but not succeeded, please update your question to reflect that plus your code you tried. – LU RD Oct 19 '16 at 15:57
  • I did not want to use the wakelock method because the code is so complex, i prefer the "FLAG_KEEP_SCREEN_ON" method, a single line (at least thats what i think.) – Ronaldinho Oct 19 '16 at 22:44
  • @RemyLebeau Can you open up this question again and remove the duplicate mark. A wake lock is something COMPLETELY different from a FLAG_KEEP_SCREEN_ON. See the [documentation here](https://developer.android.com/training/scheduling/wakelock.html). If a FLAG_KEEP_SCREEN_ON is enough you shouldn't use a wake lock. `Creating and holding wake locks can have a dramatic impact on the host device's battery life. ... As described above, if you want to keep the screen on in your activity, use FLAG_KEEP_SCREEN_ON.`. – Rik Oct 24 '16 at 18:41
  • 1
    @Rik: no, I will not reopen this question. I have instead added a new answer to the other linked question showing how to use `FLAG_KEEP_SCREEN_ON`. – Remy Lebeau Oct 24 '16 at 21:34
  • @RemyLebeau Ok, thanks. I will put a comment there because putting it in FormCreate() doesn't seem to work. Putting it under Application.Initialize in the main-project does work. – Rik Oct 25 '16 at 08:36

0 Answers0