在这里我发布了myservice.java的一部分,我想在android中的其他类中传递“服务”类的arraylist;所以怎么做,我对android非常天真。我想设置guestorderlist arraylist的值在列表视图中。
public void onStart(Intent intent, int startId) {
// TODO Auto-generated method stub
super.onStart(intent, startId);
Toast.makeText(this, "service got started", Toast.LENGTH_LONG).show();
Log.d("Testing", "Service got started");
{
{
// getting JSON string from URL
JSONObject json = jParser.makeHttpRequest(url_all_guests, "GET", params);
// Check your log cat for JSON reponse
Log.d("All custinfo: ", json.toString());
try {
// Checking for SUCCESS TAG
int success = json.getInt(TAG_SUCCESS);
if (success == 1) {
// custinfo found
// Getting Array of custinfo
custinfo = json.getJSONArray(TAG_CUSTINFO);
// looping through All custinfo
for (int i = 0; i < custinfo.length(); i++) {
JSONObject c = custinfo.getJSONObject(i);
// Storing each json item in variable
String id = c.getString(TAG_PID);
String gname = c.get(TAG_GNAME).toString();
// creating new HashMap
HashMap<String, String> map = new HashMap<String, String>();
// adding each child node to HashMap key => value
map.put(TAG_PID, id);
map.put(TAG_GNAME, gname);
// adding HashList to ArrayList
guestsorderList.add(map);
}
}
} catch (JSONException e) {
e.printStackTrace();
}
}
}
}