I am creating an game using accelerometer in libgdx and while playing the game, it sleeps after some, i need awake this untill game-play. i got this in some forums
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
which work for android app,but don't how to do that in libgdx, it is unrecognizable by compiler.any help will be appreciated.
Best and easiest way to do that is
Go to the android folder of your project in android studio
then locate AndroidLauncher.java in src sub-folder
then copy and paste code below
@Override protected void createWakeLock(boolean use) { use=true; super.createWakeLock(use); }
after adding code whole file will look like this
public class AndroidLauncher extends AndroidApplication { @Override protected void onCreate (Bundle savedInstanceState) { super.onCreate(savedInstanceState); AndroidApplicationConfiguration config = new AndroidApplicationConfiguration(); initialize(new MyBomber(), config);
}
@Override protected void createWakeLock(boolean use) { use=true; super.createWakeLock(use); } }