I run this code :
protected Object doInBackground(Object[] objects) {
HttpClient client = new HttpClient();
client.get(get_token, new HttpResponseCallback() {
@Override
public void success(String responseBody) {
runOnUiThread(new Runnable() {
@Override
public void run() {
llHolder.setVisibility(View.VISIBLE);
}
});
token = responseBody;
}
And the responseBody gives me back :
{"response":{"token":"eyJ2ZXJzaW9uIjoyLCJhdXRob3JpemF0aW9uRmlJ9","status":"success"}}
How do I get "token" as a string , same for "status"
Use this code.
protected Object doInBackground(Object[] objects) {
HttpClient client = new HttpClient();
client.get(get_token, new HttpResponseCallback() {
@Override
public void success(String responseBody) {
runOnUiThread(new Runnable() {
@Override
public void run() {
llHolder.setVisibility(View.VISIBLE);
try {
JSONObject jObject = new JSONObject(responseBody);
String token = jObject.getString("token");
} catch (JSONException e) {
e.printStackTrace();
}
}
});
}
for more info look this answer
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.