2

I am making an Android App which has a feature that allows users to upload and view PDF files. And for the app, Firebase is the backbone. At the current stage of the app, the PDF files get uploaded to Firebase Storage. But I am having a hard time viewing it. I get the download URL from Firebase and use it in the method: webView.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url=" + downloadURL) But the WebView shows me a grey background with "No Preview Available" written in the centre. I've opened the download URL on my browser and it displays the file perfectly (indicating that the file exists). How can i fix this issue?

2
  • Add your code as to how you are getting the downloadURL Commented Sep 4, 2017 at 13:19
  • Check my code below for reference Commented Apr 2, 2020 at 18:20

1 Answer 1

3

just write one line above

 pdf_url=getArguments().getString("pdf_url"); //Ur Firebase Url progressBar=view.findViewById(R.id.course_content_progress); webView=view.findViewById(R.id.pdfviewr); webView.getSettings().setJavaScriptEnabled(true); webView.setWebViewClient(new WebViewClient() { @Override public void onPageStarted(WebView view, String url, Bitmap favicon) { super.onPageStarted(view, url, favicon); } @Override public void onPageFinished(WebView view, String url) { super.onPageFinished(view, url); } }); String url=""; try { url=URLEncoder.encode(pdf_url,"UTF-8"); //Url Convert to UTF-8 It important. } catch (UnsupportedEncodingException e) { e.printStackTrace(); } webView.loadUrl("http://drive.google.com/viewerng/viewer?embedded=true&url="+url); 

it's work for me.

Happy Coding

Sign up to request clarification or add additional context in comments.

2 Comments

Can you elaborate on the answer? Why did it work for you? :-) This helps users understand your answer.
I understand What you want. So I did Something Just Checked.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.