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.
Asked
Active
Viewed 603 times
1
-
Please check the following link here http://stackoverflow.com/questions/4038479/android-go-back-to-previous-activity – Jibran Khan May 08 '13 at 11:33
-
Is the activity the same where you load the webview or you load it on a new one? – AlexBcn May 08 '13 at 11:40
-
show some code that you have tried so far or else explain your question a bit more. – Spring Breaker May 08 '13 at 11:50
-
@AlexBcn No Both are different activities. – DKHirani Dec 30 '19 at 07:20
1 Answers
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