-1

I have Some PDF Files in my google drive account so how i can view that pdf files in android studio using intent or webview. How i can do that.

 public String co="https://drive.google.com/file/d/1kr3y_2EI8-uyDeMI5DpMFLnMQDVqI-3Z/view?usp=sharing"
 webview.loadURL(co);

this code is not working.

  • you can try searching about Google drive intent and open the file directly in Drive app through intent or content resolvers – Mustahsan Jul 20 '18 at 07:36
  • 1
    Possible duplicate of [Open online pdf file through android intent?](https://stackoverflow.com/questions/23240469/open-online-pdf-file-through-android-intent) – Vikasdeep Singh Jul 20 '18 at 07:58

1 Answers1

0

I think you are missing webView.getSettings().setJavaScriptEnabled(true);

    public String co="https://drive.google.com/file/d/1kr3y_2EI8-uyDeMI5DpMFLnMQDVqI3Z/view?usp=sharing"
     webView.getSettings().setJavaScriptEnabled(true);
     webview.loadURL(co);

Or you can use:

Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri.parse(https://drive.google.com/file/d/1kr3y_2EI8-uyDeMI5DpMFLnMQDVqI3Z/view?usp=sharing));
startActivity(browserIntent);

Also make sure the url is valid.

Sachin
  • 4,110
  • 2
  • 16
  • 27
ravi
  • 832
  • 7
  • 29