android intent在线文件,通过android intent打开在线pdf文件?

目前我有一个pdf网址,我想简单地使用意图打开它,但是,如果我把网址放在意图中它不起作用

我的代码是这样的,它总是抛出ActivityNotFoundException错误

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.parse(law.url), "application/pdf");

try {

startActivity(intent);

} catch (ActivityNotFoundException e){

Utility.showErrorDialog(

ctx,ctx.getResources().getString(R.string.sys_in,

ctx.getResources().getString(R.string.err_no_pdf_reader),

ctx.getResources().getString(R.string.close));

}

我也尝试了goolge doc方法,但是我的客户拒绝了这个,所以我没有使用这种方法

Intent intent = new Intent(Intent.ACTION_VIEW);

intent.setDataAndType(Uri.parse("http://docs.google.com/viewer?url="

+ publish.get(Integer.parseInt((String) view.getTag())).pdfURL), "text/html");

ctx.startActivity(intent);

感谢帮助

Log cat错误更新

04-23 18:18:50.487: E/AndroidRuntime(17161): android.content.ActivityNotFoundException: No Activity found to handle Intent { act=android.intent.action.VIEW dat=http://oshc.zizsoft.com/oshc_testing.pdf typ=application/pdf }

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1568)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1439)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.app.Activity.startActivityForResult(Activity.java:3356)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.app.Activity.startActivityForResult(Activity.java:3317)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.support.v4.app.FragmentActivity.startActivityFromFragment(FragmentActivity.java:848)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.support.v4.app.Fragment.startActivity(Fragment.java:878)

04-23 18:18:50.487: E/AndroidRuntime(17161): at com.example.oshpedia.Fragment.Shelf$4.onItemClick(Shelf.java:142)

04-23 18:18:50.487: E/AndroidRuntime(17161): at it.sephiroth.android.library.widget.AdapterView.performItemClick(AdapterView.java:299)

04-23 18:18:50.487: E/AndroidRuntime(17161): at it.sephiroth.android.library.widget.AbsHListView.performItemClick(AbsHListView.java:972)

04-23 18:18:50.487: E/AndroidRuntime(17161): at it.sephiroth.android.library.widget.AbsHListView$PerformClick.run(AbsHListView.java:2511)

04-23 18:18:50.487: E/AndroidRuntime(17161): at it.sephiroth.android.library.widget.AbsHListView$1.run(AbsHListView.java:3200)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.os.Handler.handleCallback(Handler.java:615)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.os.Handler.dispatchMessage(Handler.java:92)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.os.Looper.loop(Looper.java:137)

04-23 18:18:50.487: E/AndroidRuntime(17161): at android.app.ActivityThread.main(ActivityThread.java:4882)

04-23 18:18:50.487: E/AndroidRuntime(17161): at java.lang.reflect.Method.invokeNative(Native Method)

04-23 18:18:50.487: E/AndroidRuntime(17161): at java.lang.reflect.Method.invoke(Method.java:511)

04-23 18:18:50.487: E/AndroidRuntime(17161): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)

04-23 18:18:50.487: E/AndroidRuntime(17161): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)

04-23 18:18:50.487: E/AndroidRuntime(17161): at dalvik.system.NativeStart.main(Native Method)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值