Example usage for android.os PowerManager FULL_WAKE_LOCK

List of usage examples for android.os PowerManager FULL_WAKE_LOCK

Introduction

In this page you can find the example usage for android.os PowerManager FULL_WAKE_LOCK.

Prototype

int FULL_WAKE_LOCK

To view the source code for android.os PowerManager FULL_WAKE_LOCK.

Click Source Link

Document

Wake lock level: Ensures that the screen and keyboard backlight are on at full brightness.

Usage

From source file:Main.java

public static void wakeLockOn(Context context) {
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    if (wl == null)
        wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "CLOCK_ALARM");
    wl.acquire();/*from  w w w. j a  va  2  s. c  o  m*/
}

From source file:Main.java

public static void acquire(Context context) {
    if (wakeLock != null)
        wakeLock.release();/*from   w w w. j a v  a2  s  . co m*/

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wakeLock = pm.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,
            "WakeLock");
    wakeLock.acquire();
}

From source file:Main.java

/**
 * Wake ups the phone./*  w ww. j  a v  a  2s.co  m*/
 * @param context
 */
public static void partialWakeUpLock(Context context) {
    PowerManager pm = (PowerManager) context.getApplicationContext().getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock wakeLock = pm.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK
            | PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TAG");
    wakeLock.acquire();
}

From source file:Main.java

/**
 * Show the activity over the lockscreen and wake up the device. If you
 * launched the app manually both of these conditions are already true. If
 * you deployed from the IDE, however, this will save you from hundreds of
 * power button presses and pattern swiping per day!
 *///from  ww  w.j a v a2s .  c o m
public static void riseAndShine(Activity activity) {
    activity.getWindow().addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);

    PowerManager power = (PowerManager) activity.getSystemService(Context.POWER_SERVICE);
    PowerManager.WakeLock lock = power.newWakeLock(
            PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE,
            "wakeup!");

    lock.acquire();
    lock.release();
}

From source file:Main.java

public static void setWakeLock(Context context) {

    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
    wl = pm.newWakeLock(PowerManager.FULL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, TAG);
    wl.acquire();/*from w  ww.  ja  v a 2 s. c  o  m*/
}

From source file:com.uob.achohan.hdr.HDR.java

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    mWL = ((PowerManager) getSystemService(Context.POWER_SERVICE)).newWakeLock(PowerManager.FULL_WAKE_LOCK,
            "WakeLock");
    mWL.acquire();/*  w w w.  j a  v a  2  s .  c o  m*/
    setContentView(R.layout.main);

    Display display = getWindowManager().getDefaultDisplay();
    Point displayDim = new Point();
    display.getSize(displayDim);

    final DrawerLayout drawer = (DrawerLayout) findViewById(R.id.drawer_layout);
    final ListView navList = (ListView) findViewById(R.id.drawer);
    List<DrawerItem> dataList = new ArrayList<DrawerItem>();

    dataList.add(new DrawerItem("HDR", new String[] { "On", "Off" }));

    CustomDrawerAdapter adapter = new CustomDrawerAdapter(this, R.layout.custom_drawer_item, dataList);
    navList.setAdapter(adapter);
    navList.setOnItemClickListener(new ListView.OnItemClickListener() {
        @Override
        public void onItemClick(AdapterView<?> parent, View view, final int pos, long id) {
            drawer.setDrawerListener(new DrawerLayout.SimpleDrawerListener() {
                @Override
                public void onDrawerClosed(View drawerView) {
                    super.onDrawerClosed(drawerView);
                }
            });
            drawer.closeDrawer(navList);
        }
    });

    mView = (MyGLSurfaceView) findViewById(R.id.surfaceviewclass);
    mView.setDisplayDim(displayDim);
}

From source file:org.apache.cordova.powermanagement.PowerManagement.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    PluginResult result = null;//from   w  w w . j  a v  a  2  s  . c  om
    Log.d("PowerManagementPlugin", "Plugin execute called - " + this.toString());
    Log.d("PowerManagementPlugin", "Action is " + action);

    try {
        if (action.equals("acquire")) {
            if (args.length() > 0 && args.getBoolean(0)) {
                Log.d("PowerManagementPlugin", "Only dim lock");
                result = this.acquire(PowerManager.SCREEN_DIM_WAKE_LOCK);
            } else {
                result = this.acquire(PowerManager.FULL_WAKE_LOCK);
            }
        } else if (action.equals("release")) {
            result = this.release();
        } else if (action.equals("setReleaseOnPause")) {
            try {
                this.releaseOnPause = args.getBoolean(0);
                result = new PluginResult(PluginResult.Status.OK);
            } catch (Exception e) {
                result = new PluginResult(PluginResult.Status.ERROR, "Could not set releaseOnPause");
            }
        }
    } catch (JSONException e) {
        result = new PluginResult(Status.JSON_EXCEPTION, e.getMessage());
    }

    callbackContext.sendPluginResult(result);
    return true;
}

From source file:org.deviceconnect.android.deviceplugin.wear.activity.WearTouchProfileActivity.java

@Override
protected void onCreate(final Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    PowerManager powerManager = (PowerManager) getSystemService(POWER_SERVICE);
    mWakeLock = powerManager.newWakeLock((PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.FULL_WAKE_LOCK
            | PowerManager.ACQUIRE_CAUSES_WAKEUP), "TouchWakelockTag");

    getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
    if (!mWakeLock.isHeld()) {
        mWakeLock.acquire();//  www. ja v a  2 s.  co  m
    }

    // Get intent data.
    setRegisterEvent(getIntent());
    setContentView(R.layout.activity_wear_touch_profile);
    mGestureDetector = new GestureDetector(this, mSimpleOnGestureListener);

    // For service destruction suppression.
    Intent i = new Intent(WearConst.ACTION_WEAR_PING_SERVICE);
    LocalBroadcastManager.getInstance(this).sendBroadcast(i);
}

From source file:uk.co.workingedge.phonegap.plugin.PowerManagement.java

@Override
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {

    Log.d(LOG_TAG, "Plugin execute called - " + this.toString());
    Log.d(LOG_TAG, "Action is " + action);

    try {//from  www . j  a  v  a2  s . c om
        if (action.equals("acquire")) {
            String type = args.optString(0);
            if (type.equals("dim")) {
                Log.d(LOG_TAG, "Type: dim wakelock");
                this.acquire(PowerManager.SCREEN_DIM_WAKE_LOCK);
            } else if (type.equals("bright")) {
                Log.d(LOG_TAG, "Type: bright wakelock");
                this.acquire(PowerManager.SCREEN_BRIGHT_WAKE_LOCK);
            } else if (type.equals("partial")) {
                Log.d(LOG_TAG, "Type: partial wakelock");
                this.acquire(PowerManager.PARTIAL_WAKE_LOCK);
            } else {
                Log.d(LOG_TAG, "Type: full wakelock");
                this.acquire(PowerManager.FULL_WAKE_LOCK);
            }
        } else if (action.equals("release")) {
            this.release();
        }
    } catch (Exception e) {
        return false;
    }

    callbackContext.success();
    return true;
}

From source file:org.apache.cordova.plugin.PowerManagement.java

/**
 * Called by the cordova framework to handle a call to this plugin
 * @param action currently supported are 'acquire' and 'release'
 * @param data In case of action 'acquire' this may contain a parameter set to 'true' to indicate only a dim wake-lock
 *///w w w.java 2  s.c o  m
@Override
public PluginResult execute(String action, JSONArray data, String callbackId) {
    PluginResult result = null;
    Log.d("PowerManagementPlugin", "Plugin execute called - " + this.toString());
    Log.d("PowerManagementPlugin", "Action is " + action);

    try {
        if (action.equals("acquire")) {
            if (data.length() > 0 && data.getBoolean(0)) {
                Log.d("PowerManagementPlugin", "Only dim lock");
                result = this.acquire(PowerManager.SCREEN_DIM_WAKE_LOCK);
            } else {
                result = this.acquire(PowerManager.FULL_WAKE_LOCK);
            }
        } else if (action.equals("release")) {
            result = this.release();
        }
    } catch (JSONException e) {
        result = new PluginResult(Status.JSON_EXCEPTION, e.getMessage());
    }

    Log.d("PowerManagementPlugin", "Result is " + result.toString());

    return result;
}