From 3cba58ce5729e2ac19d5cc96df5197462f0d2b4c Mon Sep 17 00:00:00 2001 From: Dave Johnson Date: Wed, 7 Jul 2010 15:54:33 -0700 Subject: [PATCH] Beep does not crash your app if there is no notification sound --- framework/src/com/phonegap/Device.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/src/com/phonegap/Device.java b/framework/src/com/phonegap/Device.java index 074f72f5..922fd01f 100644 --- a/framework/src/com/phonegap/Device.java +++ b/framework/src/com/phonegap/Device.java @@ -57,9 +57,11 @@ public class Device{ { Uri ringtone = RingtoneManager.getDefaultUri(RingtoneManager.TYPE_NOTIFICATION); Ringtone notification = RingtoneManager.getRingtone(mCtx, ringtone); - for (long i = 0; i < pattern; ++i) - { - notification.play(); + if (notification != null) { // This will be the case when the phone is set to silent for example + for (long i = 0; i < pattern; ++i) + { + notification.play(); + } } }