Verifying Login Details Via Http Get : Android
I seem to be having a problem verifying user login details via http get: Here is my code : public static void login(String userName, String password) { HttpClient httpclient
Solution 1:
This exception occur when ever we are try to attempt network operation on UI thread.
publicclassLongOperationextendsAsyncTask<String, Void, String> {
@OverrideprotectedStringdoInBackground(String... params) {
// call function login(userName, password);
returnnull;
}
@OverrideprotectedvoidonPostExecute(String result) {
}
@OverrideprotectedvoidonPreExecute() {
}
@OverrideprotectedvoidonProgressUpdate(Void... values) {
}
}
How to execute the task:
new LongOperation().execute();
Don't forget to add this to AndroidManifest.xml file:
<uses-permissionandroid:name="android.permission.INTERNET"/>Also see below link to more info:-
Solution 2:
You can't do HTTP transfers on the main thread. You need to run it in an AsyncTask or another thread.
Post a Comment for "Verifying Login Details Via Http Get : Android"