2016-11-09 51 views
0

當我嘗試使用Android上的TwebBrowser從URL打開.pdf時,PDF不要打開,只是一個空白的窗口。在Android上使用TwebBrowser從URL加載pdf時出錯

TwebBrowser.Navigate('http://url/pdf/{3F6E0442-F389-4A49-8587-E02757340052}.pdf'); 

在win32上工作正常 在Android上不打開pdf。

感謝

+0

'TWebBrowser'是各自原生平臺瀏覽器的包裝。原生的win32和iOS瀏覽器支持直接查看PDF文件,而android本機瀏覽器則不支持。 –

回答

1

不要使用WebBrowser組件。使用安裝的默認應用程序打開這種類型的文件。

uses 
    Androidapi.JNI.GraphicsContentViewText, 
    Androidapi.JNI.JavaTypes, 
    FMX.Helpers.Android; 

procedure OpenFile(pFileName:string); 
var 
    Intent: JIntent; 
begin 
    Intent := TJIntent.Create; 
    Intent.setAction(TJIntent.JavaClass.ACTION_VIEW); 
    Intent.setDataAndType(StrToJURI(pFileName), StringToJString('application/pdf')); 
    SharedActivity.startActivity(Intent); 
end;