小编ksh*_*ksh的帖子

使用android intent从服务器打开pdf文件

我正在网上搜索如何在android上使用默认的pdf viewer从服务器打开pdf文件.我找到的是首先下载文件然后在意图中启动它或使用谷歌文档加载它.我不想做所有这些.我只是想从手机的默认pdf查看器直接从服务器加载它.我已经尝试打开视频网址并且有效.但是故意打开pdf网址是行不通的.以下是我的代码;

private void openFilePDF(){
        try{
            Toast.makeText(getBaseContext(), "Opening PDF... ", Toast.LENGTH_SHORT).show();
            Intent inte = new Intent(Intent.ACTION_VIEW);
            inte.setDataAndType(
                    Uri.parse("http://122.248.233.68/pvfiles/Guide-2.pdf"),
                    "application/pdf");

            startActivity(inte);
            }catch(ActivityNotFoundException e){
                Log.e("Viewer not installed on your device.", e.getMessage());
            }
    }
Run Code Online (Sandbox Code Playgroud)

有什么方法可以加载pdf网址吗?

java pdf android android-intent

8
推荐指数
2
解决办法
3万
查看次数

标签 统计

android ×1

android-intent ×1

java ×1

pdf ×1