有關在此情況下返回多個值的任何想法?我想獲得的名稱,用戶名和年齡後執行方法無法從後臺執行多個值來執行後執行
protected String doInBackground(String... params) {
try{
URL url = new URL (strUrl);
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestMethod("POST");
con.connect();
//get response from server
BufferedReader bf = new BufferedReader(new InputStreamReader(con.getInputStream()));
String value = bf.readLine();
String json = value;
JSONObject parentObject = new JSONObject(json);
JSONArray parentArray = parentObject.getJSONArray("Data");
JSONObject finalObject = parentArray.getJSONObject(parentArray.length()-1);
String name = finalObject.getString("NAME");
String username = finalObject.getString("USERNAME");
String age = finalObject.getString("AGE");
return name,username,age; //this part basically dont works
}catch(Exception e){
System.out.println(e);
}
追加三個弦以#或其他簽署並通過它 –
另一種選擇是使自定義對象來保存這些值並返回對象ct – Denny
@Denny有沒有例子? –