1

when i press ok button after filled up form on web view page it should come back to activity in android.if any one have example sample code or logic please help me. Thanks in advance.

DKHirani
  • 126
  • 1
  • 7

1 Answers1

0

You can use <a href="url"></a> instead of button and make it look like button.

Code in your webpage <a href="android://back">Ok</a>

Code in Your Java file for Android Webview

import android.content.Context;
import android.content.Intent;
import android.graphics.Bitmap;
import android.view.KeyEvent;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class MyWebViewClient extends WebViewClient {

    private Context context;

    public MyWebViewClient(Context context) {
        this.context = context;
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if(url.equals("android://back")){
              //to just close webview
              finish();  
             //to open another activity uncomment below code
             /* Intent i = new Intent(context, SecondActivity.class);
            context.startActivity(i); */
            return true;
        }
        return super.shouldOverrideUrlLoading(view, url);
    }
}
Punit Shah
  • 145
  • 1
  • 6