Evening,
I'm facing a small problem which I can't get fixed. I'm having one 'base' activity (name: TestActivity
, extending ActivityGroup
) with a history array list in it. Every time when I'm going to a new activity I'm using the following bit to load a new view.
Intent intent = new Intent(Start.this, CitySelect.class);
View view = TestActivity.group.getLocalActivityManager().startActivity("cityselect", intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP)).getDecorView();
TestActivity.group.replaceView(view);
As you can see I'm calling the replaceView
method to 'replace' the view. See below for the code:
public void replaceView(View v)
{
history.add(v);
setContentView(v);
}
In every activity I'm overriding the onBackPressed
:
@Override
public void onBackPressed()
{
TestActivity.group.back();
}
See below for the back
method:
public void back()
{
if (history.size() > 0)
{
history.remove(history.size() - 1);
if (history.size() > 0)
{
View v = history.get(history.size() - 1);
setContentView(v);
}
else
{
finish();
}
}
else
{
finish();
}
}
Now comes the problem: when I'm using the back button on my phone and the previous activity comes to the foreground nothing will be called in the view (activity). When I follow the Activity life cyle I thought that the onResume
will be called but that's not the case. Nothing happens.
So the question is: How can I call the onResume
method when I'm pressing the back button?