本文整理匯總了Java中android.webkit.CookieManager.removeAllCookies方法的典型用法代碼示例。如果您正苦於以下問題:Java CookieManager.removeAllCookies方法的具體用法?Java CookieManager.removeAllCookies怎麽用?Java CookieManager.removeAllCookies使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類android.webkit.CookieManager
的用法示例。
在下文中一共展示了CookieManager.removeAllCookies方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: clearCookies
import android.webkit.CookieManager; //導入方法依賴的package包/類
@SuppressLint("NewApi")
@SuppressWarnings("deprecation")
public void clearCookies() {
// TODO Break out web storage deletion into its own option/action
// TODO clear web storage for all sites that are visited in Incognito mode
WebStorage storage = WebStorage.getInstance();
storage.deleteAllData();
CookieManager c = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
c.removeAllCookies(null);
} else {
CookieSyncManager.createInstance(this);
c.removeAllCookie();
}
}
示例2: removeAllCookiesV21
import android.webkit.CookieManager; //導入方法依賴的package包/類
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
private static void removeAllCookiesV21() {
final CookieManager cookieManager = CookieManager.getInstance();
Looper looper = Looper.myLooper();
boolean prepared = false;
if (looper == null) {
Looper.prepare();
prepared = true;
}
// requires a looper
cookieManager.removeAllCookies(new ValueCallback<Boolean>() {
@Override
public void onReceiveValue(Boolean value) {
Thread thread = new Thread() {
@Override
public void run() {
// is synchronous, run in background
cookieManager.flush();
}
};
thread.start();
}
});
if (prepared) {
looper = Looper.myLooper();
if (looper != null) {
looper.quit();
}
}
}
示例3: closeApp
import android.webkit.CookieManager; //導入方法依賴的package包/類
public static void closeApp (final Activity activity, WebView webView) {
sharedPref = PreferenceManager.getDefaultSharedPreferences(activity);
sharedPref.edit().putString("started", "").apply();
sharedPref.edit().putInt("closeApp", 1).apply();
if (sharedPref.getBoolean ("clearCookies", false)){
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookies(null);
cookieManager.flush();
}
if (sharedPref.getBoolean ("clearCache", false)){
webView.clearCache(true);
}
if (sharedPref.getBoolean ("clearForm", false)){
webView.clearFormData();
}
if (sharedPref.getBoolean ("history", false)){
activity.deleteDatabase("history_DB_v01.db");
webView.clearHistory();
}
Handler handler = new Handler();
handler.postDelayed(new Runnable() {
@Override
public void run() {
activity.finish();
}
}, 500);
}
示例4: clearCookies
import android.webkit.CookieManager; //導入方法依賴的package包/類
public static void clearCookies(@NonNull Context context) {
CookieManager c = CookieManager.getInstance();
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
c.removeAllCookies(null);
} else {
//noinspection deprecation
CookieSyncManager.createInstance(context);
//noinspection deprecation
c.removeAllCookie();
}
}