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();
}