Support keeping system awake while downloading anything

This commit is contained in:
drdev
2016-04-17 20:33:38 +00:00
parent 27e0451026
commit 4b5e6acbc0
9 changed files with 49 additions and 2 deletions

View File

@@ -17,6 +17,7 @@ import android.net.NetworkInfo;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.view.WindowManager;
import android.webkit.MimeTypeMap;
import com.badlogic.gdx.Gdx;
@@ -210,5 +211,15 @@ public class Main extends AndroidApplication {
FileUtil.deleteFile(switchOrientationFile);
}
}
@Override
public void preventSystemSleep(boolean preventSleep) {
if (preventSleep) {
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
else {
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
}
}
}
}