Reputation: 20379
I am pretty much new to android so please forgive if I sound very much immature.
I have activity A, activity B two completely independent activities. Assume I have Activity C, which gets launched when I tap on some button in Activity A. The same activity C can also be launched by tapping some other button in Activity B.
Now my doubt is I need to show UP button on activity C. I know that I need to specify parent activity for activity C in manifest file. But here in my case I have 2 different activities one of them will be parent at any given point. So how can I specify two parents activity names for activity C? How can I dynamically handle that?
Thanks in advance.
Upvotes: 2
Views: 95
Reputation: 17142
Actually, you don't need to specify the C
activity's parent in the manifest file; just intercept the click on the home button, & finish
your activity : you shall return to the previous, caller one:
ActivityC.java
@Override
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home: // Intercept the click on the home button
finish();
return true;
}
return super.onOptionsItemSelected(item);
}
Upvotes: 1