When you call Android's WebView load URL, the solution is to add a session to the URL that needs to be accessed, because the session that needs to log in causes the URL to not display:
String Reporturl = "http://xxx.xxx.xx"; Cookiesyncmanager.createinstance (Getapplication ()); Cookiemanager Cookiemanager = Cookiemanager.getinstance (); Cookiesyncmanager.getinstance (). Startsync (); list<cookie> Sessioncookie = Myapplication.getappcookie (); String re= Cookiemanager.getcookie (reporturl); if (Sessioncookie! = null) {for (int i = 0; i < sessioncookie.size (); i++) { Cookie cookie = Sessioncookie.get (i); String cookiestring=cookie.getname () + "=" + Cookie.getvalue () //path and domain must be added + "; Path= "+ cookie.getpath () +"; Domain= "+ cookie.getdomain (); Cookiemanager.setcookie (Reporturl, cookiestring); } String re2= Cookiemanager.getcookie (reporturl); Cookiesyncmanager.getinstance (). sync (); }
Where Sessioncookie is placed in MyApplication when logged in:
HttpPost HttpPost = new HttpPost (URL);
Httppost.setentity (new urlencodedformentity (params, "UTF-8")); Httpclient.getparams (). Setintparameter ("http.socket.timeout", +); = Httpclient.execute (httppost); = entityutils.tostring (response.getentity (), HTTP. Utf_8); " HTTP Response: "+ result); List<Cookie> cookies = Httpclient.getcookiestore (). GetCookies (); Myapplication.setappcookie (cookies);
You can then load the URL:
Mywebview.getsettings (). setjavascriptenabled (true); Mywebview.getsettings (). Setsupportzoom (true); Mywebview.getsettings (). setappcacheenabled (true); //Setting the cache modemywebview.getsettings (). Setcachemode (Websettings.load_default); Mywebview.loadurl (Reporturl); Mywebview.getsettings (). Setbuiltinzoomcontrols (true); Mywebview.getsettings (). Setusewideviewport (true); Mywebview.getsettings (). Setlayoutalgorithm (Layoutalgorithm.single_column); Mywebview.getsettings (). Setloadwithoverviewmode (true); Mywebview.setwebviewclient (Newwebviewclient () { Public BooleanShouldoverrideurlloading (WebView view, String URL) {//Override this method to indicate that clicking on a link in the Web page or jumping in the current webview does not jump to the browser .view.loadurl (URL); return true; }});
Session synchronization when loading Web pages with WebView