Created
November 8, 2012 23:53
-
-
Save chrisallenlane/4042711 to your computer and use it in GitHub Desktop.
PhoneGap: preventing an Android application's screen from sleeping
This file contains 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
package com.chrisallenlane.presentationtimerpro; | |
import android.app.Activity; | |
import android.os.Bundle; | |
import org.apache.cordova.*; | |
// add the following import statements | |
import android.view.WindowManager; | |
import android.view.Window; | |
public class PresentationTimerPro extends DroidGap | |
{ | |
@Override | |
public void onCreate(Bundle savedInstanceState) | |
{ | |
super.onCreate(savedInstanceState); | |
// this is the specific line that prevents the screen from sleeping | |
getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); | |
super.loadUrl("file:///android_asset/www/index.html"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment