As mentioned above, I checked this by going to the "Developer Options" and turning on "Do Not Perform Actions".
Using this methodology, I see that the original intention is preserved when the action is deleted from memory.
onDestroy is called immediately when I leave the action. When I get back to the original action, onCreate is called with the same values ββin the Intent as it was originally sent.
The following code was used as a test bench.
public class MyActivity extends Activity { @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.main); String extra = getIntent().getStringExtra("test"); ((TextView) findViewById(R.id.test)).setText(extra); } public void onClick(View view) { Intent i = new Intent(this, MyActivity.class); i.putExtra("test", ""+Math.random()); startActivity(i); } @Override protected void onDestroy() { Log.d("Test", "onDestroy"); super.onDestroy();
}
So, to answer your question, saving Intent data is redundant in onSavedInstanceState. You should just save everything that has changed or should be preserved, but not preserved forever.
source share