소스 검색

Sound wird unter Android immer abgespielt, falls GET_TASKS permission fehlt

Sebastián Katzer 12 년 전
부모
커밋
52e84d0055
1개의 변경된 파일7개의 추가작업 그리고 2개의 파일을 삭제
  1. 7 2
      src/android/LocalNotificationReceiver.java

+ 7 - 2
src/android/LocalNotificationReceiver.java

@@ -87,8 +87,13 @@ public class LocalNotificationReceiver extends BroadcastReceiver {
 		.setTicker(options.getTitle())
 		.setSmallIcon(options.getIcon());
 
-		if (!context.getPackageName().equalsIgnoreCase(((ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE)).getRunningTasks(1).get(0).topActivity.getPackageName())) {
-			// app is in background
+		try {
+			if (!context.getPackageName().equalsIgnoreCase(((ActivityManager)context.getSystemService(Context.ACTIVITY_SERVICE)).getRunningTasks(1).get(0).topActivity.getPackageName())) {
+				// app is in background
+				notification.setDefaults(Notification.DEFAULT_SOUND);
+			}
+		} catch (Exception e) {
+			// missing GET_TASKS permission
 			notification.setDefaults(Notification.DEFAULT_SOUND);
 		}