Code example for Vibrator

Methods: hasVibrator, vibrate

0
		builder.show();
	} 
	 
	private void vibrate() { 
		vibrator = (Vibrator) getSystemService(Activity.VIBRATOR_SERVICE);
		if(vibrator.hasVibrator())
			vibrator.vibrate(VIBRATE_PATTERN, 0);
	} 
	 
	private void playRingtone() { 
		String defaultAlarm = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM).toString();
		String alarm = PrefManager.getString(this, R.string.preference_timer_alarm_ringtone_key, defaultAlarm);
		try { 
			mediaPlayer = new MediaPlayer();
			mediaPlayer.setDataSource(this, Uri.parse(alarm));
			mediaPlayer.setAudioStreamType(AudioManager.STREAM_ALARM);
			mediaPlayer.setLooping(true);
			mediaPlayer.prepare();
			mediaPlayer.start();
		} catch(IOException e) { e.printStackTrace(); }
	}