android - 如何在 Android 的通知中打开浏览器?

标签 android

通过通知,我想打开一个链接到媒体文件的 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/

相关文章:

android - 设计一个仅限安卓平板电脑的应用程序

Android audiomanager - 我想设置静音模式,但应用了优先模式( Lollipop )

android - 如何将 Android SnackBar 调整到屏幕上的特定位置

android - 在 android 中接收的 FCM 数据有效负载不是 json 格式

android - 从另一个 Activity 返回后如何恢复任何 Activity 中的数据?

android-如何实现文本观察器,示例

java - 如何使用复选框删除 ListView 项目?

android - 使用默认标题 TextView 样式在 android 中自定义标题文本

java - 如何从 URL 获取 token 并在 Instagram 授权后重定向回应用程序?

android - 无法在 Ubuntu 11.10 上启动 Android Emulator - 确保 SDK 目录设置正确