gpt4 book ai didi

android - 从下一个 Activity 的 Json 响应中提取 json 字符串,即身份验证 token 。

转载 作者:行者123 更新时间:2023-11-29 01:17:30 26 4
gpt4 key购买 nike

*在 postExecute() 上

@Override
protected void onPostExecute(String s) {
if (s != null) {
s.replaceAll("\\s+","");
Log.e("Fetch_frame_response", s);
userToken = s.substring(24,451);
Log.e("userToken", userToken);
Intent abc = new Intent(MainActivity.this, Orderlist.class);
startActivity(abc);
finish();
} else {
Intent abc = new Intent(MainActivity.this, MainActivity.class);
startActivity(abc);
Toast.makeText(MainActivity.this, "Invalid credentials", Toast.LENGTH_LONG).show();
}
}
}
}

*logcat 响应没有获取我想要存储为变量 userToken 的值

07-29 10:30:57.556 7341-7341/com.example.rinzinchoephel.driverdemo2 E/userToken: 2791d970-c11d-48f6-92f3-8ec4f0b14820","contactEmail":"rchomphel@gmail.com","contactPhones":"+19731488021","createdAt":"2016-07-04T01:42:11.452-05:00","description":"","email":"rchomphel@gmail.com","id":"577a051469702d0380170000","internalId":"rinzin","lastAccessedOn":"2016-07-04T01:42:11.452-05:00","name":"rinzin choephel","phone":"+19731488021","updatedAt":"2016-07-04T01:42:11.452-05:00","userType":"merchant","username":"r

最佳答案

试试这个:

   @Override
protected void onPostExecute(String s) {
if (s != null) {
Log.e("Fetch_frame_response", s);
try {
JSONObject object=new JSONObject(s);
String userToken=object.getString("authenticationToken");
Log.e("userToken",userToken);
} catch (JSONException e) {
e.printStackTrace();
}
Intent abc = new Intent(MainActivity.this, Orderlist.class);
startActivity(abc);
finish();
} else {
Intent abc = new Intent(MainActivity.this, MainActivity.class);
startActivity(abc);
Toast.makeText(MainActivity.this, "Invalid credentials", Toast.LENGTH_LONG).show();
}
}
}
}

关于android - 从下一个 Activity 的 Json 响应中提取 json 字符串,即身份验证 token 。,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38650853/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com