[英]When I Embed a website (wordpress blog) on my android app it opens in another browser?
I just start android developing and I want to embed my website in the app. 我刚刚开始进行android开发,我想将我的网站嵌入到应用程序中。 When I want to open " http://www.google.com " , webpage opens in My app, but when I change address to my blog it wants to open it on external browser. 当我想打开“ http://www.google.com ”时,网页会在我的应用程序中打开,但是当我将地址更改为博客时,它想在外部浏览器上打开它。 This is My activity code that I used to embed my site! 这是我用来嵌入网站的活动代码!
public class WebPage extends Activity {
@SuppressLint("SetJavaScriptEnabled") @Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_web_page);
//web view start
WebView med = (WebView) findViewById(R.id.webView1);
med.getSettings().setJavaScriptEnabled(true);
med.getSettings().
med.loadUrl("http://www.mediratour.com");
}
}
My webpage based on wordpress, I don't know if I have to change settings to prevent using external browser and opens it in My app. 我的网页基于wordpress,我不知道是否需要更改设置以防止使用外部浏览器并在“我的应用”中打开它。
Thanks 谢谢
// Set this on your web view.
webView.setWebViewClient(new WebClient());
// Create this class.
public class WebClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(final WebView webView, final String url) {
webView.loadUrl(url);
return true;
}
}
I think it helps. 我认为这会有所帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.