Browse Source

Enable going back in history with backpress on Android if history is available; otherwise, destroy the webview activity. The user is still able to immediately leave the webview with the button present on the top left corner.

Mohammed Al Sahaf 8 years ago
parent
commit
30b269d5e5

+ 4 - 0
android/src/main/java/com/flutter_webview_plugin/WebviewActivity.java

@@ -76,6 +76,10 @@ public class WebviewActivity extends Activity {
 
     @Override
     public void onBackPressed() {
+        if(webView.canGoBack()){
+            webView.goBack();
+            return;
+        }
         FlutterWebviewPlugin.channel.invokeMethod("onBackPressed", null);
         super.onBackPressed();
     }