I have an android application, and wanted to know how do I open a PDF file that will be in Firebase in my application. I do not need it to download the file, simply an attempt where I pass the file path (in this case the link) and when clicking the button the default android application open and render the file. What I have been doing now is a webview that opens the pdf link in google docs, but is no longer working and therefore I wanted the pdf to be opened through the standard mobile reader. Below is the Java code for the button that calls the webview:
public void onClick(View v) {
//Intent intent = new Intent(PdfList.this, WebViewPDF.class);
//startActivity(intent);
String pdf = "AQUI ENTRA O LINK DO PDF NO FIREBASE";
WebViewPDF.OpenPDF.setPdf(pdf);
Intent intent = new Intent(PdfList.this, WebViewPDF.class);
startActivity(intent);
}
And below the webview code that opens the on-screen PDF within the application
protected void onCreate(Bundle savedInstanceState){
super.onCreate(savedInstanceState);
String pdf = OpenPDF.getPdf();
WebView mWebView = new WebView(WebViewPDF.this);
mWebView.getSettings().setJavaScriptEnabled(true);
mWebView.getSettings().setPluginState(WebSettings.PluginState.ON);
mWebView.loadUrl("https://docs.google.com/gview?embedded=true&url=" + pdf);
setContentView(mWebView);
}
public abstract static class OpenPDF extends WebViewPDF{
private static String pdf;
public static void setPdf(String pdfLink){
pdf = pdfLink;
}
public static String getPdf(){
return pdf;
}
}