如何通过“arraylist of”;服务“;android中的其他类中的类

如何通过“arraylist of”;服务“;android中的其他类中的类,android,android-listview,android-service,Android,Android Listview,Android Service,这里我发布了myservice.java的一部分,我想在android的其他类中传递“service”类的arraylist;所以如何做到这一点,我对android非常幼稚。我想在listview中设置guestorderlistarraylist的值 public void onStart(Intent intent, int startId) { // TODO Auto-generated method stub super.onStart(intent, startId

这里我发布了myservice.java的一部分,我想在android的其他类中传递“service”类的arraylist;所以如何做到这一点,我对android非常幼稚。我想在listview中设置guestorderlistarraylist的值

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();
            }


        }
    }

      }
public void onStart(Intent Intent,int startId){
//TODO自动生成的方法存根
super.onStart(intent,startId);
Toast.makeText(此“服务已启动”,Toast.LENGTH_LONG.show();
Log.d(“测试”、“服务启动”);
{
{
//从URL获取JSON字符串
JSONObject json=jParser.makeHttpRequest(url_all_guests,“GET”,params);
//检查日志cat中的JSON响应
Log.d(“所有custinfo:,json.toString());
试一试{
//检查成功标签
int success=json.getInt(TAG_success);
如果(成功==1){
//找到客户信息
//获取custinfo数组
custinfo=json.getJSONArray(TAG_custinfo);
//循环浏览所有custinfo
对于(int i=0;ivalue
地图放置(标签PID,id);
地图。放置(标记_GNAME,GNAME);
//将哈希列表添加到ArrayList
添加(地图);
}
} 
}捕获(JSONException e){
e、 printStackTrace();
}
}
}
}

我从您的问题中得到的是,您希望将ArrayList从一个活动传递到另一个活动。如果这是一个问题,您可以将ArrayList从父活动之一传递给被调用的活动。以下是一个示例:

ArrayList<TYPE> value = new ArrayList<TYPE>();
// populate the list
value.add(1.0);
Intent intent = new Intent(CurrentActivity.this,TargetActivity.class);
intent.putExtra("arraylist", value);
startActivity(intent);
ArrayList value=new ArrayList();
//填充列表
增值(1.0);
意向意向=新意向(CurrentActivity.this,TargetActivity.class);
intent.putExtra(“arraylist”,值);
星触觉(意向);
在目标类中,可以按如下方式检索列表:

// Call in in OnCreate()
// TYPE can be String, Double etc.
ArrayList<TYPE> list=(ArrayList<TYPE>)getIntent().getSerializableExtra("arraylist");
//在OnCreate()中调用
//类型可以是字符串、双精度等。
ArrayList=(ArrayList)getIntent().getSerializableExtra(“ArrayList”);

如果所需的类扩展了服务,那么我们就不能使用getIntent()