Android Screen Sleep

Android Screen Sleep

Android Torch Application Code.

I was developing an application where user has to see the screen as long as he is interacting with my application. In this scenario user screen may go Off if user is inactive for some time. To avoid screen sleep while user is reading the screen you need to add below line of code when your application gets started.

    public void onCreate(Bundle savedInstanceState) {

onCreate method gets called when activity is created.

I have also modified application manifest file AndroidManifest.xml.

<uses-permission android:name="android.permission.WAKE_LOCK" />

This takes the permission from user to keep phone awake.

The code is very useful for those who would like to develop application like Torch. :)


Android Screen SleepAndroid WebView ExampleAndroid EditText TutorialAndroid Button onClickListener ExampleAndroid Button ClickAndroid Tutorial For BeginnersBest Android ApplicationsHow to earn money with android phoneHow to remove android applicationsC# Thread SleepAndroid install APK from computer application


My name is Satalaj, but people call me Sat. Here is my homepage: . I live in Pune, PN and work as a Software Engineer. I'm former MVP in year 2010.
Disclaimer: Views or opinion expressed here are my personal research and it has nothing to do with my employer. You are free to use the code, ideas/hints in your projects. However, you should not copy and paste my original content to other web sites. Feel free to copy or extend the code.
If you want to fight with me, this website is not for you.

I'm Satalaj.