I have a little problem that is driving me crazy. I have a Class (NOT AN ACTIVITY) which extends the Java class "Thread". In this cass I download some PostJson variables into the Run() method.
in this Run() method I call the constructor of an Object and I check him the just downloaded Json variables so that I create a new Object. All of this in a for cicle that for each collection in JsonPost, create a new object.
public class GetChargePoint extends Thread{
JSONObject obj;
JSONArray jArray;
InputStream inputStream = null;
Handler handler;
private ConnectionSource connectionSource;
public ArrayList<ChargePoint_db> chargePointList = null;
public GetChargePoint(Handler handler) {
super();
this.handler = handler;
try {
} catch (MalformedURLException ex) {
ex.printStackTrace();
}
}
@Override
public void run() {
...
for (int i = 0; i < jArray.length(); i++) {
try {
JSONObject oneObject = jArray.getJSONObject(i);
String name = oneObject.getString("Name");
String address = oneObject.getString("Address");
String description = oneObject.getString("Description");
String ownerTelNumber = oneObject
.getString("OwnerTelNumber");
String serialNumber = oneObject.getString("SerialNumber");
String dateModified = oneObject.getString("DateModified");
String id = oneObject.getString("Id");
int pointModelId = oneObject.getInt("PointModelId");
int maxNominalPowerKw = oneObject
.getInt("MaxNominalPowerkW");
boolean hasAcceleratedCharge = oneObject
.getBoolean("HasAcceleratedCharge");
boolean isInMaintenance = oneObject
.getBoolean("IsInMaintenance");
boolean active = oneObject.getBoolean("Active");
boolean isDeleted = oneObject.getBoolean("IsDeleted");
boolean hasFastCharge = oneObject
.getBoolean("HasFastCharge");
double latitude = oneObject.getDouble("Latitude");
double longitude = oneObject.getDouble("Longitude");
//calling the constructor.
Object object= new Object(id,
serialNumber, name, description, address,
maxNominalPowerKw, hasAcceleratedCharge,
hasFastCharge, ownerTelNumber, false, pointModelId,
active, isInMaintenance, 0, dateModified, latitude,
longitude);
chargePoint.save(repo);
chargePointList.add(object);
...
So far so good. But as you can see, I want to fill into an ArrayList "chargePointList all new object I create.
The problem is that when into another activity I call this class to get the ArrayList, this return null. How can I share filled arraylist between a Class and other activities??
thanks :)