Skip to content Skip to sidebar Skip to footer

Android Webview Prevent Page Reload

I have a Phonegap packaged application that opens a PDF Viewer when a button is pressed. I did it with the FileOpener2 plugin. When I go back to the application from the PDF Viewer

Solution 1:

Answering my own question, setting the following properties to the only Acivity in AndroidManifest solves the problem. However I have to test it because it could have problems that I don't know:

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

Cheers!

Update

After testing a bug appeared selection a photo in the Gallery with Phonegap Camera plugin that shows "Selection cancelled".

So after reading https://groups.google.com/forum/#!topic/phonegap/R08vOZNm580 I set:

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

Solution 2:

In android.webkit.WebViewClient onLoadResource callback invoke stopLoading of WebView

MyWebViewClient extend WebViewClient {

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

Post a Comment for "Android Webview Prevent Page Reload"