If you want to display a PDF file in your android application which is located at the remote server then you have to follow the instructions given below.
Add this web-view in your xml file.
<WebView
android:id="@+id/webView"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
Add this code in onCreate method in your Activity.
WebView webView=(WebView)findViewById(R.id.webView);
webView.getSettings().setJavaScriptEnabled(true);
webView.setWebViewClient(new Callback());
String url="path of remote pdf";
webView.loadUrl("https://docs.google.com/viewer?url=" + url);
Add this method in your Activity.
private class Callback extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(
WebView view, String url) {
return(false);
}
}
Hope you find it helpful :)
0 Comment(s)