--------------------------------------------------------------------------------------------------------------------------------------
Url alert;
NotificationManager manger = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification();
notification.sound=alert.parse("android.resource://" + getPackageName() + "/" +R.raw.beepd);
manger.notify(1, notification);
--------------------------------------------------------------------------------------------------------------------------------------
不管什麼資源,透過此方式就可以將raw指定給android內建的一些函數, 例如:
MediaPlayer,Notification,VideoView,ImageView,但是檔案格式要符合Android的支援格式。
另個例子:
--------------------------------------------------------------------------------------------------------------------------------------
Url alert;
VideoView vv;
vv.setVideoURI=alert.parse("android.resource://" + getPackageName() + "/" +R.raw.myVideo);
:
:
--------------------------------------------------------------------------------------------------------------------------------------
Android reference:
http://developer.android.com/guide/topics/ui/notifiers/notifications.html
Android通知声音与资源加载
本文介绍了如何在Android中为Notification设置自定义声音,并展示了如何使用URL加载本地资源的方法,适用于Notification、MediaPlayer等多种场景。
1315

被折叠的 条评论
为什么被折叠?



