I’ve just begun developing android apps, so I need some help with my webview app which is easy to understand. So, this is my specific question:
How can I force a webview app to open links in it instead of open them in the default browser depending on domain?
Please enclose an edited/expanded version of this code with your answer:
public class WebViewActivity extends Activity {
private WebView webView;
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.webview);
webView = (WebView) findViewById(R.id.webView1);
webView.getSettings().setJavaScriptEnabled(true);
webView.loadUrl("www.example.com");
The domain whose content I want to open in webview is, let’s say: http://www.qwerty.com Every other link should be open by the default browser.
Many thanks in advance.
You’ll have to create a
WebViewClient:And then set it to your
WebViewlike this: