How to open doc file in android from url

android, doc, google-docs

Solution

try this

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);

    }
}

EDIT: IF not work, check your URL in device browser to ensure it is working fine

Problem

I want to read doc file from url in my android application, i am doing it with google docs like below but i am not getting result. ``` webView.loadUrl("http://docs.google.com/gview?embedded=true&url="+urlOfDocument); ``` is there any solution about that? how can i achieve it? Thank You

Original source

Related problems