1
我試圖展示這個應用程式中的文件的預覽,但我沒有得到確切的辦法做到這一點。同時我顯示預覽通過使用其他應用程序與下面的代碼如何在應用程序中顯示文檔預覽?
File file = new File(filePath);
Intent intent = new Intent(Intent.ACTION_VIEW);
MimeTypeMap mimeTypeMap = MimeTypeMap.getSingleton();
String fileExtension = filePath.substring(filePath.lastIndexOf(".") + 1);
fileExtension = fileExtension.toLowerCase();
if(mimeTypeMap.getMimeTypeFromExtension(fileExtension) != null) {
String type = mimeTypeMap.getMimeTypeFromExtension(fileExtension);
String fp = "file//"+filePath.substring(4);
if(isTablet(activity))
{
if(fileExtension.equals("txt"))
{
intent.setDataAndType(Uri.fromFile(file), "text/plain");
}
else
{
intent.setDataAndType(Uri.fromFile(file), type);
}
}
else
{
intent.setDataAndType(Uri.fromFile(file), type);
}
try{
activity.startActivityForResult(intent, Constants.REQUEST_AUTHENTICATION_COMPLETED);
}catch(android.content.ActivityNotFoundException e){
System.out.println("exception : "+e.getLocalizedMessage());
}
}
這工作正常但現在我想在應用程序中顯示受支持文件的預覽。我知道,QLPreview視圖控制器是iOS的,我也提到了「What is the counterpart of iOS' QLPreviewController or UIDocumentInteractionController on Android?」,但沒有運氣,所以請協助我在此.....在此先感謝
這在Android中不可行。 –
我已經看到框中的應用程序是可能的。 – Toppers