Monday, 26 July 2021

Android webview not generating pdf report on button click

I have created a web app in Android studio using WebView. I have loaded a WordPress site in android WebView. The WordPress site exports a pdf report on a button click When i load it on chrome browser.

The website loaded in chrome

enter image description here

When i click on PDF button shows the window

enter image description here

and

enter image description here

and finally it starts downloading the pdf file

enter image description here

and the generated pdf report looks like:

enter image description here

But the problem occurs when i use the Android App created in WebView. When i click on PDF button it does nothing and i get a Debug log

D/cr_Ime: [InputMethodManagerWrapper.java:59] isActive: true
[InputMethodManagerWrapper.java:68] hideSoftInputFromWindow

I have manifest permission set to

 uses-permission android:name="android.permission.INTERNET"

Code here private static final String WEB_URL = "https://ift.tt/3xYIFwa";

webView = findViewById(R.id.webView);
    
    webView.getSettings().setDomStorageEnabled(true);
    webView.getSettings().setAllowContentAccess(true);
    webView.getSettings().setDatabaseEnabled(true);
    webView.getSettings().setAllowFileAccessFromFileURLs(true);
    webView.getSettings().setAllowUniversalAccessFromFileURLs(true);
    webView.getSettings().setBlockNetworkLoads(false);

    webView.getSettings().setAppCacheMaxSize( 10 * 1024 * 1024 ); // 10MB
    webView.getSettings().setAppCachePath(getApplicationContext().getCacheDir().getAbsolutePath() );
    webView.getSettings().setAllowFileAccess( true );
    webView.getSettings().setAppCacheEnabled( true );
    webView.getSettings().setJavaScriptEnabled( true );
    webView.getSettings().setCacheMode( WebSettings.LOAD_DEFAULT );
    webView.setWebViewClient(new WebViewClient());
    webView.setWebChromeClient(new WebChromeClient());

    webView.getSettings().setJavaScriptEnabled(true);
    webView.loadUrl(WEB_URL);

Please tell is the problem related to manifest file permission or run time permission, Please give a solution.

The Android app that i created in WebView.

enter image description here



from Android webview not generating pdf report on button click

No comments:

Post a Comment