Keep screen on during android game without user interaction
android, libgdx, mobile
Solution
While JRowan's answer is good for general Android applications, and can be used with Libgdx, you can also use the Libgdx support for acquiring the wakelock. See `useWakelock` in `AndroidApplicationConfiguration`. Libgdx will keep track of the wakelock for you. You still need the appropriate permissions in your manifest, though.
Specifically, in your class that extends `AndroidApplication`:
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
AndroidApplicationConfiguration cfg = new AndroidApplicationConfiguration();
cfg.useWakelock = true;
initialize(new MyGdxGame(), cfg);
}
Problem
I'm using Libgdx for my android game. The game runs fine, but it will automatically pause while running if there is no interaction from the user. How can I avoid the game pause? My main class impelments `AndroidApplication` and my game class implements `ApplicationListener`.