Code example for PowerManager.WakeLock

Methods: setReferenceCounted

0
 
	synchronized private static WakeLock getLock(Context context) {
		if (mWakeLock == null) {
			PowerManager mPowerManager = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
			mWakeLock = mPowerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, NAME);
			mWakeLock.setReferenceCounted(true);
		} 
		return (mWakeLock);
	} 
	 
	@Override 
	public void onCreate() { 
		HandlerThread thread = new HandlerThread(NAME, Process.THREAD_PRIORITY_BACKGROUND);
		thread.start();
		 
		this.mServiceLooper = thread.getLooper();
		this.mServiceHandler = new ServiceHandler(mServiceLooper, this);
		 
		SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getApplicationContext());
		this.mTimerDelay = Long.parseLong(preferences.getString(SettingsKeys.KEY_DELAY, MessageReceiver.DEFAULT_DELAY));
Stop searching for code, let great code find you!  Add Codota to your java IDE