1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| private class MyWebViewClient extends WebViewClient {
@Override
public boolean shouldOverrideUrlLoading(WebView view, String url) {
//view.loadUrl(url);
//return true;
if (Uri.parse(url).getHost().equals("www.example.com")) {
// This is my web site, so do not override; let my WebView load the page
return false;
}
// Otherwise, the link is not for a page on my site, so launch another Activity that handles URLs
Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse(url));
startActivity(intent);
return true;
}
}
MyWebViewClient myClient = new MyWebViewClient();
webview.setWebViewClient(myClient);
String actionURL = "http://www.example.com/forum/";
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeSessionCookie();
String cookieString = "PHPSESSID=" + sessionid + "; domain=www.example.com";
cookieManager.setCookie(actionURL, cookieString);
CookieSyncManager.getInstance().sync();
webview.loadUrl(actionURL); |
Partager