Example usage for android.os PowerManager ACQUIRE_CAUSES_WAKEUP

List of usage examples for android.os PowerManager ACQUIRE_CAUSES_WAKEUP

Introduction

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

Prototype

int ACQUIRE_CAUSES_WAKEUP

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

Click Source Link

Document

Wake lock flag: Turn the screen on when the wake lock is acquired.

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();// w  w w  .j a v  a 2s . co  m
}

From source file:Main.java

public static void acquire(Context context) {
    if (wakeLock != null)
        wakeLock.release();//from  w  w  w. j  a va2  s. c  o  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 w  w . j a  va 2 s  .c  o 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

public static void acquireTemporaryWakelocks(Context context, long timeout) {
    if (wakeLock == null) {
        PowerManager powerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
        wakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP
                | PowerManager.ON_AFTER_RELEASE, "PushSMS");
    }/*from  w w w . j ava 2  s. c o m*/
    wakeLock.acquire(timeout);

    if (wifiLock == null) {
        WifiManager wifiManager = (WifiManager) context.getSystemService(Context.WIFI_SERVICE);
        wifiLock = wifiManager.createWifiLock("PushSMS");
    }

    wifiLock.acquire();
    new Handler().postDelayed(new Runnable() {
        @Override
        public void run() {
            wifiLock.release();
        }
    }, timeout);
}

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   w  ww  .j a  v a  2 s . 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();/*  w  ww .j  a v a  2  s  . c  o  m*/
}

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();//w  w  w .j  a  v  a2s . c o  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:org.deviceconnect.android.deviceplugin.wear.activity.WearKeyEventProfileActivity.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();//from w  ww . j a v  a2  s . com
    }
    setRegisterEvent(getIntent());
    setContentView(R.layout.activity_wear_keyevent_profile);

    WatchViewStub stub = (WatchViewStub) findViewById(R.id.watch_view_stub);
    stub.setOnLayoutInflatedListener(new WatchViewStub.OnLayoutInflatedListener() {
        @Override
        public void onLayoutInflated(final WatchViewStub stub) {
            mBtnKeyMode = (Button) stub.findViewById(R.id.button_key_mode);
            mBtnKeyMode.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(final View v) {
                    // Update Key Mode.
                    mKeyMode++;
                    if (mKeyMode >= KM_MAX_CNT) {
                        mKeyMode = KM_STD_KEY;
                    }

                    String keyMode;
                    switch (mKeyMode) {
                    case KM_MEDIA_CTRL:
                        keyMode = getString(R.string.key_mode_media_ctrl);
                        break;
                    case KM_DPAD_BUTTON:
                        keyMode = getString(R.string.key_mode_dpad_button);
                        break;
                    case KM_USER:
                        keyMode = getString(R.string.key_mode_user);
                        break;
                    case KM_STD_KEY:
                    default:
                        keyMode = getString(R.string.key_mode_std_key);
                        break;
                    }
                    mBtnKeyMode.setText(keyMode);
                }
            });

            mBtnCancel = (Button) stub.findViewById(R.id.button_cancel);
            mBtnCancel.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(final View view, final MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                    case MotionEvent.ACTION_DOWN:
                    case MotionEvent.ACTION_UP:
                        sendMessageData(action, KEYCODE_CANCEL);
                        break;
                    default:
                        break;
                    }
                    return false;
                }
            });

            mBtnOk = (Button) stub.findViewById(R.id.button_ok);
            mBtnOk.setOnTouchListener(new View.OnTouchListener() {
                @Override
                public boolean onTouch(final View view, final MotionEvent event) {
                    int action = event.getAction();
                    switch (action) {
                    case MotionEvent.ACTION_DOWN:
                    case MotionEvent.ACTION_UP:
                        sendMessageData(action, KEYCODE_OK);
                        break;
                    default:
                        break;
                    }
                    return false;
                }
            });

        }
    });

    Intent i = new Intent(WearConst.ACTION_WEAR_PING_SERVICE);
    LocalBroadcastManager.getInstance(this).sendBroadcast(i);
}

From source file:fr.bmartel.android.iotf.app.BaseActivity.java

protected void onCreate(Bundle savedInstance) {
    super.onCreate(savedInstance);

    sharedpreferences = getSharedPreferences(StorageConst.STORAGE_PROFILE, Context.MODE_PRIVATE);

    notifyMgr = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);

    try {//from   w ww  .  j av a2s .  com
        Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION);
        ringtone = RingtoneManager.getRingtone(getApplicationContext(), notification);

    } catch (Exception e) {
        e.printStackTrace();
        ringtone = null;
    }

    screenLock = ((PowerManager) getSystemService(POWER_SERVICE))
            .newWakeLock(PowerManager.SCREEN_BRIGHT_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "TAG");
}

From source file:cx.ring.fragments.CallFragment.java

@Override
public void onCreate(Bundle savedBundle) {
    Log.i(TAG, "onCreate");
    super.onCreate(savedBundle);

    audioManager = (AudioManager) getActivity().getSystemService(Context.AUDIO_SERVICE);

    setHasOptionsMenu(true);//from w  w  w.ja va  2s.c  o m
    PowerManager powerManager = (PowerManager) getActivity().getSystemService(Context.POWER_SERVICE);
    mScreenWakeLock = powerManager.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK
            | PowerManager.ACQUIRE_CAUSES_WAKEUP | PowerManager.ON_AFTER_RELEASE, "cx.ring.onIncomingCall");
    mScreenWakeLock.setReferenceCounted(false);

    Log.d(TAG, "Acquire wake up lock");
    if (mScreenWakeLock != null && !mScreenWakeLock.isHeld()) {
        mScreenWakeLock.acquire();
    }
}