I have a main activity and a child activity. I am using up button in child activity to return to main activity. In my activity I have some animation that I don't want to start it again when I return to it form child activity. So here is home action in child activity:
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
Intent intent = NavUtils.getParentActivityIntent(this);
intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
NavUtils.navigateUpTo(this, intent);
return true;
}
return super.onOptionsItemSelected(item);
}
And here is manifest:
<activity
android:name=".ChildActivity"
android:label="@string/app_name"
android:parentActivityName=".MainActivity" >
<!-- Parent activity meta-data to support 4.0 and lower -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value=".MainActivity" />
</activity>
When I run it on LG nexus 5 with android 4.4.4 it works fine but in Xperia arc with android 4.0.4 it starts the animation each time I return to main activity. What's the solution?
Update:
I can achieve what I want using one of these ways:
1- Just calling finish()
when up is pressed.
2- Using Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP
when adding flag to intent.
But I want to know what causes this difference in behavior in android 4.4.4 and 4.0.4.
Thanks in advance!