Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.33 KB | None | 0 0
  1.     public void syncSignalInfo() {
  2.         PowerManager pm = (PowerManager) ctx.getSystemService(Context.POWER_SERVICE);
  3.         final TelephonyManager tm = (TelephonyManager) ctx.getSystemService(Context.TELEPHONY_SERVICE);
  4.         //wakeLock = pm.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, "vnaps");
  5.         PowerManager.WakeLock wakeLock = pm.newWakeLock(PowerManager.SCREEN_DIM_WAKE_LOCK | PowerManager.ACQUIRE_CAUSES_WAKEUP, "vnaps");
  6.         synchronized (wakeLock) {
  7.             wakeLock.acquire(500);
  8.             //Log.i("VNAPS", "[YAZ] Wakelock requested: " + wakeLock.isHeld());
  9.             try {
  10.                 Thread.sleep(500);
  11.             } catch (InterruptedException e) {
  12.                 //Log.e("VNAPS", "[YAZ} Interrupted");
  13.             }
  14.             if (wakeLock.isHeld()) {
  15.                 wakeLock.release();
  16.             } else {
  17.                 Log.e("VNAPS", "Prevented a wakelock.release exception...");
  18.             }
  19.         }
  20.         //Log.i("VNAPS", "[YAZ] Asking for updated phone state");
  21.  
  22.         tm.listen(strength_listener, PhoneStateListener.LISTEN_NONE);
  23.         tm.listen(strength_listener, PhoneStateListener.LISTEN_CELL_LOCATION);
  24.         tm.listen(strength_listener, PhoneStateListener.LISTEN_CELL_INFO);
  25.         tm.listen(strength_listener, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
  26.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement