Skip to content

Commit

Permalink
Fix for brodeurlv#145
Browse files Browse the repository at this point in the history
Added an AudioAttribute with "USAGE_NOTIFICATION" to the vibration. It now seems to vibrate always, even with the screen off.
  • Loading branch information
sdriv3r committed Jul 19, 2020
1 parent ae7eed6 commit b021468
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/src/main/java/com/easyfitness/utils/AlarmReceiver.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import android.os.Build;
import android.os.VibrationEffect;
import android.os.Vibrator;
import android.media.AudioAttributes;

public class AlarmReceiver extends BroadcastReceiver {
@Override
Expand All @@ -16,7 +17,7 @@ public void onReceive(Context context, Intent arg1) {
Vibrator v = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE);
// Vibrate for 500 milliseconds
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O) {
v.vibrate(VibrationEffect.createWaveform(pattern, -1));
v.vibrate(VibrationEffect.createWaveform(pattern, -1), new AudioAttributes.Builder().setUsage(AudioAttributes.USAGE_NOTIFICATION).build());
} else {
//deprecated in API 26
if (v != null) {
Expand Down

0 comments on commit b021468

Please sign in to comment.