From d6dd8513499190a42f59f49d2f76daa157275c5d Mon Sep 17 00:00:00 2001 From: Eric House Date: Tue, 26 Jul 2016 11:49:08 -0700 Subject: [PATCH] fix NPE: ringtone can be null on older OS --- .../android/XWords4/src/org/eehouse/android/xw4/Utils.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java index 88d909336..ee10e28ac 100644 --- a/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java +++ b/xwords4/android/XWords4/src/org/eehouse/android/xw4/Utils.java @@ -35,6 +35,7 @@ import android.content.pm.PackageManager; import android.content.pm.ResolveInfo; import android.content.res.Configuration; import android.database.Cursor; +import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; import android.provider.ContactsContract.PhoneLookup; @@ -243,7 +244,10 @@ public class Utils { if ( CommonPrefs.getSoundNotify( context ) ) { Uri uri = RingtoneManager .getDefaultUri( RingtoneManager.TYPE_NOTIFICATION ); - RingtoneManager.getRingtone( context, uri ).play(); + Ringtone ringtone = RingtoneManager.getRingtone( context, uri ); + if ( null != ringtone ) { + ringtone.play(); + } } }