Upon clicking a button in an activity, I want to display Page1 if this activity has a parent activity and display Page2 if it does not (i.e. it is the Main Activity that is started when I started the application).
Yes, getParentActivityIntent()
Obtain an Intent that will launch an explicit target activity specified by this activity's logical parent. The logical parent is named in the application's manifest by the parentActivityName attribute. Activity subclasses may override this method to modify the Intent returned by super.getParentActivityIntent() or to implement a different mechanism for retrieving the parent intent entirely.
Returns a new Intent targeting the defined parent of this activity or null if there is no valid parent.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With