本文整理汇总了Java中android.webkit.CookieManager.getInstance方法的典型用法代码示例。如果您正苦于以下问题:Java CookieManager.getInstance方法的具体用法?Java CookieManager.getInstance怎么用?Java CookieManager.getInstance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.webkit.CookieManager
的用法示例。
在下文中一共展示了CookieManager.getInstance方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: reset
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void reset() {
Editor editor = mSharedPref.edit();
editor.putString(ACCESS_TOKEN, "");
editor.putString(USERID, "");
editor.putString(USERNAME, "");
editor.putString(FULLNAME, "");
editor.putString(PROFILPIC, "");
editor.putInt(FOLLOW,0);
editor.putInt(FOLLOWED,0);
editor.commit();
CookieSyncManager.createInstance(mContext);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
}
示例2: setCookie
import android.webkit.CookieManager; //导入方法依赖的package包/类
private void setCookie(Context context, String domain, String sessionCookie) {
CookieSyncManager.createInstance(context);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
if (sessionCookie != null) {
// delete old cookies
cookieManager.removeSessionCookie();
}
try {
Thread.sleep(200);
} catch (InterruptedException e) {
e.printStackTrace();
}
cookieManager.setCookie(domain, sessionCookie);
CookieSyncManager.createInstance(context);
CookieSyncManager.getInstance().sync();
}
示例3: sendResponseMessage
import android.webkit.CookieManager; //导入方法依赖的package包/类
protected void sendResponseMessage(HttpResponse response) {
super.sendResponseMessage(response);
Header[] headers = response.getHeaders("Set-Cookie");
if (headers != null && headers.length > 0) {
CookieSyncManager.createInstance(LemallPlatform.getInstance().getContext()).sync();
CookieManager instance = CookieManager.getInstance();
instance.setAcceptCookie(true);
instance.removeSessionCookie();
String mm = "";
for (Header header : headers) {
String[] split = header.toString().split("Set-Cookie:");
EALogger.i("游客登录", "split[1]===>" + split[1]);
instance.setCookie(Constants.GUESTLOGIN, split[1]);
int index = split[1].indexOf(";");
if (TextUtils.isEmpty(mm)) {
mm = split[1].substring(index + 1);
EALogger.i("正式登录", "mm===>" + mm);
}
}
EALogger.i("游客登录", "split[11]===>COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm);
instance.setCookie(Constants.GUESTLOGIN, "COOKIE_DEVICE_ID=" + LemallPlatform.getInstance().uuid + ";" + mm);
instance.setCookie(Constants.THIRDLOGIN, "COOKIE_APP_ID=" + LemallPlatform.getInstance().getmAppInfo().getId() + ";" + mm);
CookieSyncManager.getInstance().sync();
this.val$iLetvBrideg.reLoadWebUrl();
}
}
示例4: onCreate
import android.webkit.CookieManager; //导入方法依赖的package包/类
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//清除cookie
CookieSyncManager.createInstance(WebViewActivity.this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
setContentView(R.layout.activity_webview);
mWebView = (WebView) findViewById(R.id.login_webview);
mIntent = getIntent();
mUrl = mIntent.getStringExtra("extr_url");
mProgress = (ProgressBar) findViewById(R.id.login_webview_progress);
init();
}
示例5: loadUrl
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void loadUrl(final String url)
{
if (mOverrideTitle)
{
mContext.setTitle(url);
}
CookieManager cookieManager = CookieManager.getInstance();
Log.e("AUTHTOKEN", cookieManager.getCookie("https://stackexchange.com"));
Map<String, String> abc = new HashMap<>();
abc.put("Set-Cookie", cookieManager.getCookie("https://stackexchange.com"));
mWebView.loadUrl(url, abc);
cookieManager.setAcceptCookie(true);
}
示例6: removeExpiredCookies
import android.webkit.CookieManager; //导入方法依赖的package包/类
/**
* 清除过期的cookie
*/
public static void removeExpiredCookies() {
CookieManager mCookieManager = null;
if ((mCookieManager = CookieManager.getInstance()) != null) { //同步清除
mCookieManager.removeExpiredCookie();
toSyncCookies();
}
}
示例7: clearCookie
import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void clearCookie() {
CookieSyncManager cookieSyncManager = CookieSyncManager.createInstance(getContext());
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
cookieManager.removeSessionCookie();
cookieManager.removeAllCookie();
cookieSyncManager.sync();
}
示例8: updateCookiePreference
import android.webkit.CookieManager; //导入方法依赖的package包/类
@Override
public void updateCookiePreference() {
mCookieManager = CookieManager.getInstance();
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
CookieSyncManager.createInstance(this);
}
mCookieManager.setAcceptCookie(PreferenceManager.getInstance().getCookiesEnabled());
super.updateCookiePreference();
}
示例9: saveUserSessionId
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void saveUserSessionId(String userSessionId){
// save to cookie manager
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setCookie(CMBCHINA_BASIC_URL, "userSessionId=" +userSessionId);
CookieSyncManager.getInstance().sync();
// save to sharedpreference
SharedPreferenceHelper.getInstance(getApplicationContext()).saveString(CMBCHINA_SHARED_PERFERENCE_KEY_USER_SESSION_ID,userSessionId);
}
示例10: get_location
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void get_location(){
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(true);
if(ASWP_LOCATION) {
//Checking for location permissions
if (Build.VERSION.SDK_INT >= 23 && !check_permission(1)) {
ActivityCompat.requestPermissions(MainActivity.this, new String[]{Manifest.permission.ACCESS_FINE_LOCATION}, loc_perm);
show_notification(2, 2);
} else {
GPSTrack gps;
gps = new GPSTrack(MainActivity.this);
double latitude = gps.getLatitude();
double longitude = gps.getLongitude();
if (gps.canGetLocation()) {
if (latitude != 0 || longitude != 0) {
cookieManager.setCookie(ASWV_URL, "lat=" + latitude);
cookieManager.setCookie(ASWV_URL, "long=" + longitude);
//Log.w("New Updated Location:", latitude + "," + longitude); //enable to test dummy latitude and longitude
} else {
Log.w("New Updated Location:", "NULL");
}
} else {
show_notification(1, 1);
Log.w("New Updated Location:", "FAIL");
}
}
}
}
示例11: SystemCookieManager
import android.webkit.CookieManager; //导入方法依赖的package包/类
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public SystemCookieManager(WebView webview) {
webView = webview;
cookieManager = CookieManager.getInstance();
//REALLY? Nobody has seen this UNTIL NOW?
cookieManager.setAcceptFileSchemeCookies(true);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
cookieManager.setAcceptThirdPartyCookies(webView, true);
}
}
示例12: DisplayTemperatureDialog
import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
public void DisplayTemperatureDialog(@NonNull String url) {
final Dialog dialog = createDialog();
dialog.setContentView(R.layout.dialog_webview);
TextView titleView = dialog.findViewById(R.id.dialog_title_text_view);
titleView.setText("Temperature Graph");
com.rey.material.widget.Button closeButton = dialog.findViewById(R.id.dialog_button_close);
closeButton.setOnClickListener(v -> dialog.dismiss());
if (!url.startsWith("http://") && !url.startsWith("https://")) {
url = "http://" + url;
}
WebView webview = dialog.findViewById(R.id.dialog_webview);
webview.getSettings().setUseWideViewPort(true);
webview.getSettings().setBuiltInZoomControls(true);
webview.getSettings().setSupportZoom(true);
webview.getSettings().setJavaScriptEnabled(true);
webview.getSettings().setLoadWithOverviewMode(true);
webview.setWebViewClient(new WebViewClient());
webview.setInitialScale(100);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(false);
webview.loadUrl(url);
displayDialog(dialog);
}
示例13: syncCookie
import android.webkit.CookieManager; //导入方法依赖的package包/类
public static void syncCookie(String url, String cookies) {
CookieManager mCookieManager = CookieManager.getInstance();
if (mCookieManager != null) {
mCookieManager.setCookie(url, cookies);
toSyncCookies();
}
}
示例14: onReceive
import android.webkit.CookieManager; //导入方法依赖的package包/类
@SuppressLint("SetJavaScriptEnabled")
@Override
public void onReceive(Context context, Intent intent) {
_logger.Debug("_screenEnableReceiver onReceive");
_screenEnabled = true;
_centerTextView = ((Activity) _context).findViewById(R.id.centerTextView);
_centerWebView = ((Activity) _context).findViewById(R.id.centerWebView);
_centerWebView.getSettings().setBuiltInZoomControls(true);
_centerWebView.getSettings().setSupportZoom(true);
_centerWebView.getSettings().setJavaScriptEnabled(true);
_centerWebView.getSettings().setLoadWithOverviewMode(true);
_centerWebView.setWebViewClient(new WebViewClient());
_centerWebView.setWebChromeClient(new WebChromeClient());
_centerWebView.setInitialScale(100);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.setAcceptCookie(false);
_centerWebView.setWebViewClient(new WebViewClient() {
public void onPageFinished(WebView view, String url) {
_progressDialog.dismiss();
_loadingUrl = false;
}
});
_youTubePlayerView = ((Activity) _context).findViewById(R.id.centerYoutubePlayer);
if (Keys.YOUTUBE_API_KEY.length() != 0) {
_youTubePlayerView.initialize(Keys.YOUTUBE_API_KEY, CenterViewController.this);
} else {
_logger.Warn("Please enter your youtube api key!");
Toasty.error(_context, "Please enter your youtube api key!", Toast.LENGTH_LONG).show();
}
}
示例15: clearCookie
import android.webkit.CookieManager; //导入方法依赖的package包/类
public void clearCookie() {
CookieSyncManager.createInstance(this);
CookieManager cookieManager = CookieManager.getInstance();
cookieManager.removeAllCookie();
CookieSyncManager.getInstance().sync();
}