Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to open PDF file stored in remote server in android.

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 3.18k
    Comment on it

    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&#95;width="match&#95;parent"
        android:layout&#95;height="match&#95;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)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: