Android WebView prevents page reloading

I have a Phonegap-related application that opens a PDF viewer at the click of a button. I did this with the FileOpener2 plugin.

When I return to the application from the PDF viewer, the result will differ depending on the versions of Android.

In Android 4. * the application remains where it should be before leaving the application. However, in Android 2.3.7, WebView reloads the application, which I do not expect.

I already tried changing android: launchmode to singleTask or singleInstance without success.

How can I avoid reloading the page when I return to the Phonegap application?

Thanks in advance!

Update 1

I changed the Cordova or Phonegap CordovaWebViewClient class, which extends WebViewClient with

@Override
public void onLoadResource(WebView view, String url) {
    if (url.equals("file:///android_asset/www/index.html")) {
        if (this.firstLoad) {
            this.firstLoad = false;
        } else {
            view.stopLoading();
        }
    }

onLoadResource , .

+4
2

, Acivity AndroidManifest . , , :

android:launchMode="singleInstance"
android:alwaysRetainTaskState="true"

!

, Phonegap, " ".

, https://groups.google.com/forum/#!topic/phonegap/R08vOZNm580 :

 android:launchMode="singleTask"
 android:taskAffinity=""
 android:excludeFromRecents="true"
+5

android.webkit.WebViewClient onLoadResource callback stopLoading WebView

MyWebViewClient extend WebViewClient {

public void onLoadResource (WebView view, String url) {
    if(your condition ){
         view.stopLoading();
    }
}
}
+1

Source: https://habr.com/ru/post/1531328/


All Articles