I've tried this and it works, but I didn't know if this was a bad thing or not, as all the help on data transfers between Activities seems to use intents.
In MainActivity I have:
static PilotRecord pilotRecord = new PilotRecord(); //PilotRecord just contains data item declarations
In MainActivity.onCreate:
pilotRecord.fuel = 100;
In MainActivity.onClick:
Intent intent = new Intent(this, SubActivity.class);
startActivityForResult(intent, 0);
In SubActivity.onCreate I have:
MainActivity.pilotRecord.fuel = 200;
In SubActivity.onClick:
MainActivity.pilotRecord.fuel = 300;
setResult(RESULT_OK);
finish();
When I start MainActivity, the fuel value is 100
If I click in MainActivity, SubActivity is displayed, as expected
If I click in SubActivity, MainActivity is displayed and the fuel value is now 300
If I press the Back button, MainActivity is displayed and the fuel value is now 200
Does anyone know of any potential issues with this as it seems simpler to me than setting up intents etc.
- Frink