编写android应用程序,android中打开pdf,在Android应用程序中打开PDF

 2023-09-23 阅读 18 评论 0

摘要:我正在开发应用程序,需要在设备中打开pdf文件,我实际上已经获得了与大多数示例类似的网络上的代码。但是,事情是我无法打开文件,控件直接转到“Exception”部分。以下是以下代码:public class MyPDFDemo extends Activity{编写android应用

我正在开发应用程序,需要在设备中打开pdf文件,

我实际上已经获得了与大多数示例类似的网络上的代码。但是,事情是我无法打开文件,控件直接转到“Exception”部分。

以下是以下代码:

public class MyPDFDemo extends Activity

{

编写android应用程序、/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

android应用程序的四大组件、Button OpenPDF = (Button) findViewById(R.id.button);

OpenPDF.setOnClickListener(new View.OnClickListener()

{

public void onClick(View v)

{

File pdfFile = new File("/sdcard/Determine_RGB_Codes_With_Powerpoint [PDF Library].pdf");

android手机应用程序开发,if(pdfFile.exists())

{

Uri path = Uri.fromFile(pdfFile);

Intent pdfIntent = new Intent(Intent.ACTION_VIEW);

pdfIntent.setDataAndType(path, "application/pdf");

pdfIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);

android应用程序开发第三版。try

{

startActivity(pdfIntent);

}

catch(ActivityNotFoundException e)

{

安卓看pdf的软件?Toast.makeText(MyPDFDemo.this, "No Application available to view pdf", Toast.LENGTH_LONG).show();

}

}

}

});

}

android pdf、当我运行这个代码:我曾经看到“没有应用程序可以查看pdf”。任何人都可以请我查看pdf文件。

版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。

原文链接:https://hbdhgg.com/3/87896.html

发表评论:

本站为非赢利网站,部分文章来源或改编自互联网及其他公众平台,主要目的在于分享信息,版权归原作者所有,内容仅供读者参考,如有侵权请联系我们删除!

Copyright © 2022 匯編語言學習筆記 Inc. 保留所有权利。

底部版权信息