我的源代码与sapmle应用程序.
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.webkit.WebSettings;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;
public class AndroidMobileAppSampleActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
WebView mainWebView = (WebView) findViewById(R.id.mainWebView);
WebSettings webSettings = mainWebView.getSettings();
webSettings.setJavaScriptEnabled(true);
mainWebView.setWebViewClient(new MyCustomWebViewClient());
mainWebView.setScrollBarStyle(View.SCROLLBARS_INSIDE_OVERLAY);
mainWebView.loadUrl("http://qatarcarsale.com/");
}
private class MyCustomWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
return true;
}
}
}
我想只使用crome浏览器,其他浏览器不支持我的网站,我该如何解决这个问题?
1条答案
按热度按时间eyh26e7m1#
你想只使用Chrome浏览器还是不想?
澄清一下。另外,下面两个链接里有一个很好的答案。如果你想让用户选择浏览器,请看下面的链接
How to load the application in Web-View in a specific browser like Chrome or Firefox in Android
如果你想自己处理浏览器设置,请看这个,
https://stackoverflow.com/a/8941605/115145