Skip to content

Instantly share code, notes, and snippets.

@px-amaac
Created July 2, 2013 08:01
Show Gist options
  • Save px-amaac/5907510 to your computer and use it in GitHub Desktop.
Save px-amaac/5907510 to your computer and use it in GitHub Desktop.
private void startAlarm() {
// set vibrate
vibrate = (Vibrator) getSystemService(VIBRATOR_SERVICE);
long[] vibrate_pattern = { 1000, 200, 200 };
vibrate.vibrate(vibrate_pattern, 0);
//check if silent mode is on.
if (!pass.getSilent()) {
mP = new MediaPlayer();
try {
mP.setVolume(1.0f, 1.0f);
mP.setDataSource(
this,
Uri.parse(RingtoneManager.getDefaultUri(
RingtoneManager.TYPE_ALARM).toString()));
mP.setAudioStreamType(AudioManager.STREAM_ALARM);
mP.setLooping(true);
mP.prepare();
mP.start();
} catch (Exception e) {
mP.release();
alarmActive = false;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment