通过通知,我想打开一个链接到媒体文件的 url。 我的代码段如下:
Intent notificationIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(myUrl));
PendingIntent contentIntent = PendingIntent.getActivity(MyService.this, 0, notificationIntent,0);
notification.setLatestEventInfo(context, contentTitle, contentText, contentIntent);
notificationManager.notify(id, notification);
这样我在索尼爱立信手机上可以打开JEPG文件,但是不能打开mp4文件。 但是,如果在我启用通知之前已经打开浏览器,则可以成功打开mp4文件。 那么,我是否应该在 Intent 中设置一些标志?
感谢您的考虑。
迈克
最佳答案
如果您知道 URL 表示的数据的 MIME 类型,将其添加到 Intent
中会有所帮助。
关于android - 如何在 Android 的通知中打开浏览器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7121677/