Zdravím,
původem jsem .net vyvojar a s javou na androidu začínám.
Mám takový problém. Dělám UrlConnection, udělám si cookie manager, cookie handler atd...
zaloguju se někam, ale kdyz pak čtu cookies, ty co v .netu mám 4 a více, tak tady je jen sessionid.
Poradíte prosím?
private String test(String usr, String pwd, String srvr, View v) throws Exception
{
StrictMode.ThreadPolicy policy = new StrictMode.
ThreadPolicy.Builder().permitAll().build();
StrictMode.setThreadPolicy(policy);
TextView tv = (TextView) findViewById(R.id.TextView1);
////////////
CookieManager cookieManager = new CookieManager();
CookieHandler.setDefault(cookieManager);
////////////
URL url = new URL(srvr);
HttpURLConnection urlConnection = (HttpURLConnection) url.openConnection();
urlConnection.setRequestProperty("username", usr);
urlConnection.setRequestProperty("password", pwd);
urlConnection.setRequestProperty("lowRes","0");
urlConnection.setRequestProperty("w","1280:1024");
urlConnection.setRequestProperty("login","112114568");
InputStream in = new BufferedInputStream(urlConnection.getInputStream());
readStream(in);
String headerName=null;
String cookie = "";
String header = "";
CookieStore cookieJar = cookieManager.getCookieStore();
List <HttpCookie> cookies = cookieJar.getCookies();
header = header + cookies.size();
for (HttpCookie cookie1: cookies)
{
header = header + "\n" + cookie1;
}
for (int i=1; (headerName = urlConnection.getHeaderFieldKey(i))!=null; i++)
{
//header = header + "\n" + headerName + ":" + uc.getHeaderField(i);
if (headerName.equals("Set-Cookie"))
{
cookie = urlConnection.getHeaderField(i);
}
}
//DialogBuble(v, header);
EditText tb = (EditText) findViewById(R.id.TextBox1);
tb.setText(header);
//return cookie;
return header;
}