0
在Android中,我需要在视图中显示PDF文件,该文件位于asset
文件夹中。任何人都可以帮助我与示例代码?在Android的视图中显示PDF
在Android中,我需要在视图中显示PDF文件,该文件位于asset
文件夹中。任何人都可以帮助我与示例代码?在Android的视图中显示PDF
我不认为它有可能在视图中显示它。您将必须制作一个Intent
,然后调用外部程序来完成此操作。
File sd = new File("example.pdf");
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.fromFile(sd));
intent.setDataAndType(Uri.fromFile(sd), "application/pdf");
try {
getContext().startActivity(intent);
} catch(ActivityNotFoundException e){
// Show a message that a PDF viewer is not installed
Toast.makeText("No PDF reader available",Toast.LENGTH_LONG).show();
}