我正在尝试为 phonegap 应用程序中的自定义声音设置正确的 URI。我尝试了几种组合,包括以下组合,但我一直得到一个Uri cannot be resolved
notif.sound = Uri.parse("android.resource://package_name/raw/notification/alarm.WAV");
notif.sound = Uri.parse("android.resource://package_name/raw/notification/");
notif.sound = Uri.parse("file://path/to/file/alarm.WAV");
使用phonegap时如何设置声音的Uri
更多信息
我正在使用本教程,最后它解释了如何从推送消息中添加通知......
String message = extras.getString("message");
String title = extras.getString("title");
Notification notif = new Notification(android.R.drawable.btn_star_big_on, message, System.currentTimeMillis() );
notif.flags = Notification.FLAG_AUTO_CANCEL;
notif.defaults |= Notification.DEFAULT_SOUND;
notif.defaults |= Notification.DEFAULT_VIBRATE;
Intent notificationIntent = new Intent(context, TestSampleApp.class);
notificationIntent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, notificationIntent, 0);
notif.setLatestEventInfo(context, title, message, contentIntent);
String ns = Context.NOTIFICATION_SERVICE;
NotificationManager mNotificationManager = (NotificationManager)
context.getSystemService(ns);
mNotificationManager.notify(1, notif);
我认为删除Notification.DEFAULT_SOUND;
和添加uri
会使其放置自定义声音。