简体   繁体   中英

android open files from url

I am having some trouble opening few files. I have database where is description about file (id, name, type and etc). These files originaly are saved in another folder on server. Is it possible to open them if I know only url like: http:// * ** * ** /resource/view.php?id=11 ? I manage to open some files using webview, but I need to open also pdf files. By the way is it possible to open doc files on google view? because I tried and it did not opened it but it opened pdf file in next try.

WebView urlWebView = (WebView)findViewById(R.id.containWebView);
urlWebView.setWebViewClient(new AppWebViewClients());
urlWebView.getSettings().setJavaScriptEnabled(true);
urlWebView.getSettings().setUseWideViewPort(true);
urlWebView.loadUrl("http://docs.google.com/gview?embedded=true&url="
            + "YOUR_DOC_URL_HERE"); 

public class AppWebViewClients extends WebViewClient {

@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
    // TODO Auto-generated method stub
    view.loadUrl(url);
    return true;
}

@Override
public void onPageFinished(WebView view, String url) {
    // TODO Auto-generated method stub
    super.onPageFinished(view, url);

}

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM