Code example for AudioManager

Methods: getStreamMaxVolumesetRingerModesetStreamVolume

0
				if (wl.isHeld()) wl.release();
			} 
 
			if (prefs.getBoolean(CHKDISRINGVIB, false)) {
				if (prefs.getBoolean(SPNDISRINGVIBONOFF, true)) {
					audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, 
					// AudioManager.VIBRATE_SETTING_ON); 
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, 
					// AudioManager.VIBRATE_SETTING_ON); 
					// System.putInt(context.getContentResolver(), 
					// VIBRATE_IN_SILENT, 0); 
				} else { 
					audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, 
					// AudioManager.VIBRATE_SETTING_OFF); 
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, 
					// AudioManager.VIBRATE_SETTING_OFF); 
				} 
			} 
 
		} else if (intent.getExtras().getInt("state") == 1 && isConnected == false) {
			Log.d(TAG, "HeadSet connected");
 
			if (prefs.getBoolean(CHKCONAUTOROTATE, false))
				if (prefs.getBoolean(SPNCONAUTOONOFF, true)) android.provider.Settings.System
						.putInt(context.getContentResolver(),
								android.provider.Settings.System.ACCELEROMETER_ROTATION, 1);
				else android.provider.Settings.System.putInt(context.getContentResolver(),
						android.provider.Settings.System.ACCELEROMETER_ROTATION, 0);
 
			if (prefs.getBoolean(CHKCONRINGVIB, false)) {
				if (prefs.getBoolean(SPNCONRINGVIBONOFF, true)) {
					audioManager.setRingerMode(AudioManager.RINGER_MODE_VIBRATE);
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, 
					// AudioManager.VIBRATE_SETTING_ON); 
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, 
					// AudioManager.VIBRATE_SETTING_ON); 
					// System.putInt(context.getContentResolver(), 
					// VIBRATE_IN_SILENT, 0); 
				} else { 
					audioManager.setRingerMode(AudioManager.RINGER_MODE_NORMAL);
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_RINGER, 
					// AudioManager.VIBRATE_SETTING_OFF); 
					// audioManager.setVibrateSetting(AudioManager.VIBRATE_TYPE_NOTIFICATION, 
					// AudioManager.VIBRATE_SETTING_OFF); 
				} 
			} 
 
			if (prefs.getBoolean(CHKCONMEDIAVOL, false)) {
 
				int maxVol = audioManager.getStreamMaxVolume(AudioManager.STREAM_MUSIC);
 
				audioManager
						.setStreamVolume(AudioManager.STREAM_MUSIC,
								(maxVol * prefs.getInt(SKBCONMEDIAVOL, 0)) / 100,
								AudioManager.FLAG_VIBRATE);
 
				Log.d(TAG, "Setting vol: " + prefs.getInt(SKBCONMEDIAVOL, 7));
			}