According to the code sample I have shown, responseJson returns the value of FirstName. I want to get that value out of responseJson because i want to pass it to next activity. Any help will be highly appreciated.
@Override
protected void onPostExecute(JSONObject result) {
// TODO Auto-generated method stub
super.onPostExecute(result);
String myResJson;
try {
myResJson = responseJson.getString("Status");
String test = myResJson;
if (test.equals("200")) {
Intent intent = new Intent(contxt, ActivityMenu.class);
intent.putExtra("FirstName", firstname);
contxt.startActivity(intent);
} else {
Toast.makeText(contxt,
"Login Error, invalid Email or Password", Toast.LENGTH_SHORT)
.show();
}
} catch (JSONException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
this is the my responseJson value {"LastName":"A","UserID":"1","Status":"200","FirstName":"P"}
Change
intent.putExtra("FirstName", firstname);
to
intent.putExtra("FirstName", responseJson.getString("FirstName"));
OR
firstname=responseJson.getString("FirstName");
if(firstname!=null)
intent.putExtra("FirstName", firstname);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.