I have an Android app where I want to display files in pdf, excel, docx, txt formats from their respective Urls. I am able to display these files using external apps, but for this, the file is first downloaded and stored on the device and then displayed. I do not want the downloading, I tried using Google document viewer to display the files in a WebView, but since the documents are private, they wont display. I have tried something like below :-
mDocumentUrl = mIntent.getStringExtra(Constant.DOCUMENT_URL);
wvDocumentReader.getSettings().setJavaScriptEnabled(true);
wvDocumentReader.setWebViewClient(new WebViewClient(){
@Override
public void onPageStarted(WebView view, String url, Bitmap favicon)
{
super.onPageStarted(view, url, favicon);
wvProgressBar.setVisibility(View.VISIBLE);
}
@Override
public boolean shouldOverrideUrlLoading(WebView view, WebResourceRequest request)
{
view.loadUrl(request.getUrl().toString());
return true;
}
@Override
public void onPageFinished(WebView view, String url)
{
super.onPageFinished(view, url);
wvProgressBar.setVisibility(View.GONE);
}
});
wvDocumentReader.loadUrl("http://docs.google.com/gview?embedded=true&url="+ mDocumentUrl);
Can anyone suggest a library or a workaround to achieve this? Any help is appreciated.