PreferenceManager getDefaultSharedPreferences已在Android Q中弃用,该如何替换?
我需要在改装2.0中添加cookie.如果我理解正确,cookie - 与标题相同.必须添加此Cookie:
private HashMap<String, String> cookies = new HashMap();
cookies.put("sessionid", "sessionId");
cookies.put("token", "token");
Run Code Online (Sandbox Code Playgroud)
这个与Jsoup lib一起使用:
String json = Jsoup.connect(apiURL + "/link")
.cookies(cookies)
.ignoreHttpErrors(true)
.ignoreContentType(true)
.execute()
.body();
Run Code Online (Sandbox Code Playgroud)
这是我的代码与改造请求:
@GET("link")
Call<CbGet> getData(@Header("sessionid") String sessionId, @Header("token") String token);
Run Code Online (Sandbox Code Playgroud)
但它不起作用...我得到403错误代码,所以请求中没有cookie ...
任何的想法?