Android 打开pdf文档,没有阅读器链接到Google Play Store等下载
来源:互联网 发布:js调用手机图库 编辑:程序博客网 时间:2024/04/29 00:40
使用自带的pdf阅读器,打开pdf文档。如果没有阅读器,链接到android市场(Google Play Store,360手机助手等)下载。
File file = new File(pdfPath);Intent intent = new Intent("android.intent.action.VIEW");intent.addCategory("android.intent.category.DEFAULT");intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);intent.setDataAndType(Uri.fromFile(file), "application/pdf");try { startActivity(intent);} catch (ActivityNotFoundException e) { Intent marketIntent = new Intent(Intent.ACTION_VIEW); marketIntent.setData(Uri.parse("market://search?q=PDF")); startActivity(marketIntent);}
必须加try{}catch{}, 否则,如果没有阅读器,程序会崩溃报错ActivityNotFoundException。
想要了解更多market://的知识,请点击http://blog.csdn.net/liucaoye/article/details/41449059
想要了解各种类型文件(“.html”,".doc",".mp3"上百种类型)对应的setDataAndType的参数,参考 http://www.2cto.com/kf/201201/117389.html
想要了解Intent的各种跳转(email,短信,map,电话等),参考http://luhuajcdd.iteye.com/blog/1560225
0 0
- Android 打开pdf文档,没有阅读器链接到Google Play Store等下载
- Android market:// 链接到Google Play 商店
- 电脑下载google play store的apk
- 求助,android sdk manager下载google play service没有google-play-services_Lib这个文件夹
- Android app跳转google play store
- 如何从 Google Play 下载 Android 程序到电脑上
- android 打开pdf文档
- 调用google play store
- Android 下载并打开PDF,Doc,Dwg文档
- 在浏览器中下载Google play store软件
- 纯Java文档阅读器(word、pdf等)
- PDF阅读器下载
- 免费下载pdf阅读器
- html5链接直接下载文件 不是直接打开 如pdf, doc 等
- 谷歌Android Market更名为Google Play Store
- Android国行手机使用Google Play Store
- Android Market google play store帐号申请 注册方法流程
- Android: 国行手机使用Google Play Store
- 边记边学PHP-(四)PHP数据类型、常量、变量及表达式2
- Command设计模式
- MySQL触发器示例
- SIP测试工具
- 如何用Mac完美编译OpenJDK 7
- Android 打开pdf文档,没有阅读器链接到Google Play Store等下载
- ubuntu12.04 + ROS(Hydro)使用RVIZ出错
- DIV CSS技术学习难吗?
- Sicily 1157 the hardest problem
- asp.net发布中惨遭“500.19”及“500.21”迫害
- 站内信
- [postgreSQL,c++] PostgreSQL源码分析_StringInfo_primary
- 第13周项目5-字符串操作-(2.1)
- AIX crontab 0403-027 The parameter list is too long 参数过长报错