2
0
mirror of https://github.com/KDE/kdeconnect-android synced 2025-08-30 21:55:10 +00:00

TYPE_ALARM can return null. Adding a fallback.

This commit is contained in:
Albert Vaca
2016-06-01 12:56:07 +02:00
parent 01b1e6ee4a
commit 284ef5e571

View File

@@ -26,8 +26,11 @@ public class FindMyPhoneActivity extends Activity {
WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED |
WindowManager.LayoutParams.FLAG_TURN_SCREEN_ON);
Uri notification = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
ringtone = RingtoneManager.getRingtone(getApplicationContext(), notification);
Uri soundFile = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_ALARM);
if (soundFile == null) {
soundFile = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_RINGTONE);
}
ringtone = RingtoneManager.getRingtone(getApplicationContext(), soundFile);
if (android.os.Build.VERSION.SDK_INT >= 21) {
AudioAttributes.Builder b = new AudioAttributes.Builder();