I have a webview in my android app, but when someone navigates around the site, it opens in a new window, i want it to stay inside the webview.. is there a way to do this easily? Here is the code in my activity:
public class WebView1 extends Activity {
WebView web1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_view);
Intent in=getIntent();
String urll= in.getStringExtra("url");
web1=(WebView)findViewById(R.id.web);
web1.loadUrl(urll);
}
Attach a
WebViewClientto theWebView, whereshouldOverrideUrlLoading()on yourWebViewClientloads the URL into theWebViewand returns true.For example, this activity implements this approach:
(from this sample project)