所以我目前有3个异步任务正在运行Login,Registration和GetInstitutes。我首先使Login类功能,我知道它工作正常,但添加其他2导致它无法正常工作。因此,当应用程序启动时,它会执行GetInstitutes并返回
{"institute":[{"id":"1","name":"plymouh university"},{"id":"2","name":"University Of Bradford"},{"id":"3","name":"University of West England"}],"success":1}
如果我注册它返回:
{"message":"Invalid email","success":0}
这些运行正常并且JSON对象很好,但是当登录而不是获取登录的JSON对象时,我得到之前的登录之一
class loginAttempt extends AsyncTask<String, String, String>{
JSONObject json = null; //reseting the JSON Object to null to try and fix
@Override
protected void onPreExecute() {
//Show progress Dialog
}
@Override
protected String doInBackground(String... params) {
String usernameSTR = username.getText().toString();
String passwordSTR = password.getText().toString();
// Building Parameters
List<NameValuePair> params1 = new ArrayList<NameValuePair>();
params1.add(new BasicNameValuePair("username", usernameSTR));
params1.add(new BasicNameValuePair("password", passwordSTR));
Log.d("Create Response", json.toString()); //outputs null
// getting JSON Object
json = jsonParser.makeHttpRequest(url_login,
"POST", params1); //Performs Login request
Log.d("Create Response", json.toString()); //outputs original JSON from register or Get Institute not from the JSON above
//manipulate results
return null;
}
protected void onPostExecute(String file_url) {
//Dismiss Dialouge and show results
}
}