1
我想使用Android的通知管理器即android.app.Notification和android.app.NotificationManager使用下面的代码工作完全正常在我的Android设备具有OS 4.4.2。 看来他们不能在一些较旧的操作系统4.2.x上正常工作。我看到一个弹出通知,但声音是默认通知声音,而不是我选择的声音,这在我的设备上正常工作,它是4.4.2。Android通知播放默认声音,而不是自定义
Uri alarmSound = Uri.parse("/storage/sdcard1/MyApp/Media/Sounds/fire.mp3");
NotificationCompat.InboxStyle inboxStyle = new NotificationCompat.InboxStyle();
inboxStyle.setBigContentTitle(notificationString);
PendingIntent pendingIntent = PendingIntent.getActivity(context, 0,
(new Intent(context, NavigationMenu.class)),
0);
Notification notification = new NotificationCompat.Builder(context)
.setSmallIcon(R.drawable.logo_black)
.setContentTitle(notificationString)
.setContentText(notificationString)
.setContentIntent(pendingIntent)
.setAutoCancel(true)
.setSound(alarmSound)
.build();
mNotificationManager.notify(notificationId, notification);
URI是实际上不是硬编码并使用Environment.getExternalStorageDirectory()获得并且该文件是出现在指定的位置。由于这在我的设备上工作得非常好,而不是在旧设备上,所以首先想到的问题是操作系统版本,但我找不到旧版本的解决方案。
更新 因此,这似乎并没有与操作系统的问题,因为我与OS 4.2.2测试了其他Android设备,它的工作。
仍无法挖开原因...
问题是我不能这样做,因为我的应用程序具有下载所需的警报声音和在应用程序中使用的功能。 –