【问题标题】:In ICs, can`t get cookie在 IC 中,无法获取 cookie
【发布时间】:2012-06-04 10:13:53
【问题描述】:

cookie 总是返回 null...

在 android 2.x 中这很好用,但 4.0.4 ICS 不适用

ConnectivityManager manager = (ConnectivityManager) mContext
            .getSystemService(Context.CONNECTIVITY_SERVICE);
CookieManager cookie = CookieManager.getInstance();

            if(cookie.getCookie(mContext.getString(R.string.host_url))!=null){
                conn.setRequestProperty("Cookie", cookie.getCookie(mContext.getString(R.string.host_url)));
                Log.d("tag", "cookie get " +  cookie.getCookie(mContext.getString(R.string.host_url)));
            }

在这段代码中 cookie.getCookie() 总是返回 null...

*在 HttpUrlConnection 中使用此代码

【问题讨论】:

    标签: android cookies session-cookies android-4.0-ice-cream-sandwich httpurlconnection


    【解决方案1】:

    尝试在网址前添加一个点。例如,如果它是“domain.com”,则将其更改为“.domain.com” 但它仍然不适用于以前的版本。因此,请检查版本并执行其他操作。 4.0 之前的所有版本都适用于“domain.com”

    【讨论】:

      猜你喜欢
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      • 2020-07-19
      • 2022-01-12
      • 2020-07-13
      • 1970-01-01
      • 1970-01-01
      • 2017-04-28
      相关资源
      最近更新 更多