Added vibration to alarm

This commit is contained in:
Doug Keen 2012-10-09 14:43:48 -07:00
parent 13d4ed51c2
commit 699a40e93b
2 changed files with 11 additions and 1 deletions

View File

@ -2,11 +2,12 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.dougkeen.bart"
android:installLocation="auto"
android:versionCode="22"
android:versionCode="23"
android:versionName="2.1.0-beta" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-sdk
android:minSdkVersion="8"

View File

@ -17,6 +17,7 @@ import android.os.Bundle;
import android.os.Handler;
import android.os.IBinder;
import android.os.Parcelable;
import android.os.Vibrator;
import android.support.v4.app.LoaderManager.LoaderCallbacks;
import android.support.v4.content.CursorLoader;
import android.support.v4.content.Loader;
@ -243,6 +244,10 @@ public class ViewDeparturesActivity extends SActivity implements
if (application.getAlarmMediaPlayer() == null) {
tryToPlayRingtone(alarmSound);
}
final Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
if (vibrator.hasVibrator()) {
vibrator.vibrate(new long[] { 0, 500, 500 }, 1);
}
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
@ -270,6 +275,10 @@ public class ViewDeparturesActivity extends SActivity implements
final MediaPlayer mediaPlayer = application.getAlarmMediaPlayer();
application.setAlarmSounding(false);
application.setAlarmMediaPlayer(null);
final Vibrator vibrator = (Vibrator) getSystemService(VIBRATOR_SERVICE);
if (vibrator.hasVibrator()) {
vibrator.cancel();
}
try {
if (mediaPlayer != null && mediaPlayer.isPlaying()) {
mediaPlayer.stop();