Logging In Via Httppost To A Website Via An Application
Hello Stackoverflowers! I have written a relatively simple application that consists of a login text field, a password text field and a login button. My goal is that when the user
Solution 1:
My guess is that your application doesn't handle cookies right. Take a look at this question, it may help.
WebView and Cookies on Android
EDIT
In your code you seem to pass only the html retrieved from request to the WebView. Cookies seem to get lost somewhere. I'd suggest you another approach.
@OverridepublicvoidonCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
WebView webv = (WebView)findViewById(R.id.MainActivity_webview);
webv.setWebViewClient(newWebViewClient(){
@OverridepublicbooleanshouldOverrideUrlLoading(WebView view, String url) {
view.loadUrl(url);
returntrue;
}
});
String postData = FIELD_NAME_LOGIN + "=" + LOGIN +
"&" + FIELD_NAME_PASSWD + "=" + PASSWD;
// this line logs you in and you stay logged in// I suppose it works this way because in this case WebView handles cookies itself
webv.postUrl(URL, EncodingUtils.getBytes(postData, "utf-8"));
}
Post a Comment for "Logging In Via Httppost To A Website Via An Application"