I want something like that.i have a button and 2 textbox when user put their username and password and then click on login button then login action will be performed and then welcome the user and go to another page .my code was like that:
try {
Connection.Response res = Jsoup.connect("URL")
.data("log", "abcd", "pwd", "12345", "wp-submit", "প্রবেশ", "redirect_to", "url", "testcookie", "1")
.method(Method.POST)
.execute();
Map<String, String> cookies = res.cookies();
Document doc2 = Jsoup
.connect("new_url")
.cookies(cookies)
.get();
s = doc2.text().toString();
t.setText(s);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
t.setText("no");
}
But login action cant be successful and here it always shows “no”.
How can i successfully do that???
i think it is threading problem. because your internet request is on main UI-Thread. test this:
and call it as
Edited:
you cannot perform an internet request on main UI-Thread. that is why u need a different thread. now u could implement a simple thread instead of
AsyncTask. then why i suggest u to useAyncTask. the answer is, u cannot update your UI from a simple Thread. that is why u needAsyncTask, becauseAsyncTaskgives u flexibility to update UI but execute your method in different Thread beside UI-Thread.