I got an ArrayList<MyClass>
that is filled with Measure
objects, i got from the acceleration sensor of a cell phone. The objects have another ArrayList with 150 measure values. When I investigate on this Arraylist while debugging, it is getting filled correctly. But after i want to take that ArrayList with a button event, the values have changed. the number of objects inside stays the same, but its alway one identical object, that wasnt in the ArrayList before. I hope, you could give me a little hint what to do here. Its so confusing...
public class StartDesk extends AppCompatActivity implements SensorEventListener{
private ArrayList<SingleSwing> alSwingsCurSession;
private ArrayList<SingleAccValue> alSavedAccValues;
private AudioSensorClass asc;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_start_desk);
...
alSavedAccValues = new ArrayList<>();
bRecording = false;
btnStart = (Button) findViewById(R.id.btnStart);
btnStart.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
RecordButtonHandler();
}
});
}
private void RecordButtonHandler() {
if(!bRecording) {
alSwingsCurSession = new ArrayList<>();
...
}
else {
btnStart.setText("Start Recording");
if (alSwingsCurSession.size() > 0) {
...
}
bRecording = false;
}
}
...
private void SaveSwingINI(ArrayList<SingleAccValue> al_SavedAccValues) {
if(al_SavedAccValues.size()>=150) {
SingleSwing swing = new SingleSwing();
swing.setAl_MeasureData(al_SavedAccValues);
alSwingsCurSession.add(swing);
}
}
...
}
alSwingsCurSession
has other values, when calling it at the button events, then it gets in the SaveSwingINI
method. I got no static fields in my Classes.