Code example for Activity

Methods: getSystemServicesetVolumeControlStreamgetClass

0
	 
	public void disableKeyguard(Activity activity) {
		if (mKeyguardLock != null) {
			mKeyguardLock.disableKeyguard();
		} else { 
			KeyguardManager keyguardManager = (KeyguardManager) activity.getSystemService(Activity.KEYGUARD_SERVICE);
			mKeyguardLock = keyguardManager.newKeyguardLock(KEYGUARD_TAG);
			mKeyguardLock.disableKeyguard();
		} 
	} 
	 
	public void enableKeyguard() { 
		if (mKeyguardLock != null) {
			mKeyguardLock.reenableKeyguard();
		} 
		mKeyguardLock = null;
	} 
 
 
	public void onSharedPreferenceChanged(SharedPreferences prefs, String key) {
		if (key.equals(PREF_KEYGUARD_DISABLED)) {
			mKeyguardState = Integer.parseInt(prefs.getString(PREF_KEYGUARD_DISABLED, KEYGUARD_STATUS_ENABLED));
			if (mKeyguardState == INT_KEYGUARD_STATUS_ALL)
				disableKeyguard(mActivity);
			else 
				enableKeyguard(); 
		} 
	} 
	 
	public void onActivityResume(Activity activity) {
		switch (mKeyguardState) {
			case INT_KEYGUARD_STATUS_REMOTE_ONLY:
				if(activity.getClass().equals(RemoteActivity.class))
					disableKeyguard(activity);
				else 
					enableKeyguard(); 
				break; 
			case INT_KEYGUARD_STATUS_ALL:
				disableKeyguard(activity);
				break; 
			default: 
				enableKeyguard(); 
				break; 
		} 
		 
		activity.setVolumeControlStream(AudioManager.STREAM_MUSIC);
		mActivity = activity;
	} 
	 
	public void onActivityPause() { 
		if (mKeyguardLock != null){
Experience pair programming with AI  Get Codota for Java