Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Hard to say what is wrong without seeing the code, but I would advise you to use the Intent extras to move your data between activities. You will need to make your Vehicle class implement <a href="http://developer.android.com/reference/android/os/Parcelable.html" rel="nofollow">Parcelable</a> (there is an example of how to implement Parcelable on that page, and countless others on the net). You pass your object as extra to the intent launching your UpgradeActivity like this :</p> <pre><code>Intent upgradeIntent = new Intent(this, UpgradeActivity.class); upgradeIntent.putExtra("com.example.model.Vehicle", yourVehicleObject); startActivityForResult(upgradeIntent, UPGRADE_CAR_REQUEST_CODE); //UPGRADE_CAR_REQUEST_CODE is a unique private static final int </code></pre> <p>Then you can retrieve it in your UpgradeActivity onCreate method :</p> <pre><code>Intent intent = getIntent(); Vehicle vehicleFromLastActivity = intent.getParcelableExtra("com.example.model.Vehicle"); </code></pre> <p>Before going back to your MainActivity you do something like this :</p> <pre><code>Intent dataIntent = new Intent(); dataIntent.putExtra("com.example.model.Vehicle", yourModifiedVehicleObject); setResult(RESULT_OK, dataIntent); finish(); </code></pre> <p>Then finally in MainActivity you need to handle the result, it is done like this :</p> <pre><code>@Override public void onActivityResult(int requestCode, int resultCode, Intent data) { super.onActivityResult(requestCode, resultCode, data); switch(requestCode) { case UPGRADE_CAR_REQUEST_CODE: if(resultCode == android.app.Activity.RESULT_OK) { Vehicle modifiedObject = data.getParcelableExtra("com.example.model.Vehicle"); // Now you can use that object which is coming from UpgradeActivity } } } </code></pre> <p>Of course this could cause issues if your Vehicle class takes a lot of memory. You could then consider passing only the relevant information through the Intent to rebuild the object in the UpgradeVehicle Activity, for example only the id &amp; name.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload