我正在开发应用程序,需要在设备中打开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文件。
版权声明:本站所有资料均为网友推荐收集整理而来,仅供学习和研究交流使用。
工作时间:8:00-18:00
客服电话
电子邮件
admin@qq.com
扫码二维码
获取最新动态