Skip to content

Instantly share code, notes, and snippets.

@chrisallenlane
Created November 8, 2012 23:53
Show Gist options
  • Save chrisallenlane/4042711 to your computer and use it in GitHub Desktop.
Save chrisallenlane/4042711 to your computer and use it in GitHub Desktop.
PhoneGap: preventing an Android application's screen from sleeping
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