2012-05-10 18 views

回答

0

將PDF的查看交給另一個應用程序(如Adobe Reader)可能是最佳選擇。

使用一個意圖:

Intent i = new Intent(Intent.ACTION_VIEW); 
File pdf = new File(FILE_LOCATION); 
i.setDataAndType(Uri.fromFile(pdf), "application/pdf"); 
startActivity(i); 

我們還應該考慮如果用戶沒有使用PDF閱讀器的情景:

Intent i = new Intent(Intent.ACTION_VIEW); 
File pdf = new File(FILE_LOCATION); 
i.setDataAndType(Uri.fromFile(pdf), "application/pdf"); 

List<ResolveInfo> list = getPackageManager().queryIntentActivities(i, 
       PackageManager.MATCH_DEFAULT_ONLY); 
if(!list.isEmpty()){ 
    startActivity(i); 
}else{ 
    Toast.makeText(this, "A PDF reader is required to open this.", Toast.LENGTH_LONG).show(); 
} 
0
First u install the acrobat reader in ur emulator and the u view ur pdf file in emulator. 
Download acrobat reader apk and install in emulator using this command from command line. 
1. Go to start and open run. 
2. type cmd and type "adb -e install FilePath" press enter. 
Then u go to ur application and write this code for viewing pdf in acrobat reader. 
Intent i = new Intent(Intent.ACTION_VIEW); 
File pdf = new File(<File name whit full path>); 
i.setDataAndType(Uri.fromFile(pdf), "application/pdf"); 
startActivity(i); 
+0

如何使用滾動活動查看下一頁的PDF意圖 –

+0

當pdf查看活動開始顯示在acrobat閱讀器中時。在該視圖中,您可以滾動並查看文件中的所有頁面。打開文件的所有頁面。 –