Created
February 4, 2015 15:47
-
-
Save billmote/06820b5c4051d700af9c to your computer and use it in GitHub Desktop.
Keep the screen on while the activity is visible.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class KeepScreenOn extends Activity { | |
| @Override | |
| protected void onCreate(Bundle savedInstanceState) { | |
| super.onCreate(savedInstanceState); | |
| setContentView(R.layout.activity_keepscreenon); | |
| } | |
| @Override | |
| protected void onResume() { | |
| super.onResume(); | |
| this.getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | |
| } | |
| @Override | |
| protected void onPause() { | |
| this.getWindow().clearFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | |
| super.onPause(); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment