在清单网络中提供访问权限。我在活动类中有一个Web视图,如果我使用intent事件并使用移动浏览器提示用户,它就可以工作。
但是当我尝试在Web视图中加载它时,它不会加载。
任何帮助,这里都是代码:
public class DirectToWebActivity extends Activity {
private WebView webView;
private String url = "https://m.sportsbet.com.au";
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.web_view);
webView = new WebView(this);
webView.getSettings().setJavaScriptEnabled(true);
final Activity activity = this;
webView.setWebViewClient(new WebViewClient() {
public void onReceivedError(WebView view, int errorCode, String description, String failingUrl) {
//todo
}
});
webView .loadUrl(url);
setContentView(webView);
}
}
答案 0 :(得分:0)
尝试这些代码行
long delayInMillis = 10000;
Timer timer = new Timer();
timer.schedule(new TimerTask() {
@Override
public void run() {
// show progress bar here until the web view is not loaded
}
}, delayInMillis);
/////FIND THE WEB VIEW ID FROM THE LAYOUT LIKE BELOW
WebView webview = (WebView)view.findViewById(R.id.webview);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.setWebViewClient(new WebViewClient());
webview.loadUrl("PASTE YOUR URL HERE");