我需要在我的android應用程序中顯示本地pdf,這個pdf需要包含在我的應用程序包中,我有這個但我不知道如何構建File
類。如何在android中打開本地PDF?
public void loadreglamento(View v){
//Im supposed to give a path with the file but I really dont know how
Uri path = Uri.fromFile(file);
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndType(path, "application/pdf");
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
startActivity(intent);
}
此代碼是好對我來說,我不關心,如果用戶看到外部查看/編輯文檔。
我還需要知道我必須複製PDF文件的位置。
在此先感謝。
https://stackoverflow.com/questions/30549807/cannot-open-pdf-file-in-external-app/30549924#30549924 – CommonsWare