I am trying to do this, and I really need help from expirienced fellows.
- App with 2 texboxes. One for username, and one for password.
- Button for login.
- When user press button, login information is sent to webpage (m.bonbon.hr), and that webpage is opened in browser.
- After first login, login information is saved so that user doesn’t have to enter that information again.
Where to start from, please any guidelines, advices, i’ll take anything.
EDIT:
I created this in my main acctivity
DefaultHttpClient httpclient = new DefaultHttpClient();
HttpPost httpost = new HttpPost("https://www.bonbon.hr/registracija?direct=1");
try {
List<NameValuePair> nvps = new ArrayList<NameValuePair>();
nvps.add(new BasicNameValuePair("email", "login"));
nvps.add(new BasicNameValuePair("password", "pw"));
nvps.add(new BasicNameValuePair("autologin", "true"));
httpost.setEntity(new UrlEncodedFormEntity(nvps));
}
catch (UnsupportedEncodingException e) {
// writing error to Log
e.printStackTrace();
}
try {
HttpResponse response = httpclient.execute(httpost);
// writing response to log
Log.d("Http Response:", response.toString());
} catch (ClientProtocolException e) {
// writing exception to log
e.printStackTrace();
} catch (IOException e) {
// writing exception to log
e.printStackTrace();
}
Under the onCreate part. So now , when i click on my button (already created and ready for use) i need to login to given URL with given information… But I don’t know how to makle it happen using asyntask 🙁
Design the layout of the appliaction with the two text boxes and one button to login.
Now, when that button is pressed get the text entered in the two TextBoxes using
getText()and makePOSTrequest to the webpage URL and maintain a session using HttpClient.If you are planning to save user login information, SharedPreferences is the best way to do it and you can store the username and the password in the SharedPreference variables and use them later to make later requests to log in.
And in case you want to know more about how to use HttpClient to establish a session, this question would provide you with a lot of answers.