After user inputs parameters in MainActivity
for my app (shown below), he taps Search
, which calls MatchesActivity
, which generates output on a new screen (shown further below), which is exited via tapping back
.
But with MatchesActivity
active, every time the device is rotated, Search
is again executed because the Activity
restarts. In the screenshot below, I rotated device from vertical to horizontal to vertical to horizontal back to vertical.
The output is generated in MatchesActivity
that is invoked in onCreate
in MainActivity
like so:
Intent matchesIntent;
matchesIntent = new Intent(MainActivity.this, MatchesActivity.class);
startActivity(matchesIntent);
Here's the essence of onCreate
for MatchesActivity
:
@Override protected void onCreate(Bundle savedInstanceState)
{
MainActivity.dbc.setDbProcesslistener(this); // to know txaMatches has been defined
MainActivity.dbc.findDBMatches(); // generate output
}
I did research. I found some complicated ways of preventing an activity from restarting when the device is rotated. For example .
I'm hoping for a simpler solution. Any ideas?