Ich habe eine Frage betreffend Android Cookies.
Ich erstelle einen Login-Cookie der wie folgt ab Android 2.3 funktioniert:
1private void createCookie() {
2
3 Map<String, List<String>> allHeaderFields = connection.getHeaderFields();
4 List<String> allCookieFields = allHeaderFields.get("Set-Cookie");
5
6 for (int i = 0; i < allCookieFields.size(); i++) {
7
8 List<HttpCookie> cookies = HttpCookie.parse(allCookieFields.get(i));
9
10 for (int j = 0; j < cookies.size(); j++) {
11
12 HttpCookie cookie_http = cookies.get(j);
13 String cookieKey = cookie_http.getName();
14 String cookieValue = cookie_http.getValue();
15
16 if (cookieKey.equals("saml")) {
17 loginCookie = cookieValue;
18 } // IF
19
20 } // For
21
22 } // For
23 }
2
3 Map<String, List<String>> allHeaderFields = connection.getHeaderFields();
4 List<String> allCookieFields = allHeaderFields.get("Set-Cookie");
5
6 for (int i = 0; i < allCookieFields.size(); i++) {
7
8 List<HttpCookie> cookies = HttpCookie.parse(allCookieFields.get(i));
9
10 for (int j = 0; j < cookies.size(); j++) {
11
12 HttpCookie cookie_http = cookies.get(j);
13 String cookieKey = cookie_http.getName();
14 String cookieValue = cookie_http.getValue();
15
16 if (cookieKey.equals("saml")) {
17 loginCookie = cookieValue;
18 } // IF
19
20 } // For
21
22 } // For
23 }
Nun will ich aber die App auch auf einem Android 2.2 Smartphone installieren und da gibt es "HttpCookie" noch nicht.
Kann mir jemand eine Info geben, wie der Code für Android 2.2 dann aussehen könnte.
Habe jetzt schon in einigen Foren gesucht und div. Möglichkeiten versucht, bekomm es jedoch nicht hin.
Vielen Dank im Voraus für eure Hilfe!
Danke,
Verena
