I have the following in my AndroidManifest.xml file:
<activity
android:name=".PickemAllPicksResultsActivity"
android:label="@string/title_activity_backActionBar"
android:parentActivityName=".PoolDetailsActivity"
android:screenOrientation="portrait" />
The above places a back button/arrow (in the action bar) in my child view in order to navigate back to the parent view.
I have the following layout for the child view:
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".PickemAllPicksResultsActivity" >
<com.google.android.material.tabs.TabLayout
android:id="@+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Weekly" />
<com.google.android.material.tabs.TabItem
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Overall" />
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager2.widget.ViewPager2
android:id="@+id/viewPager"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/tabLayout"
android:layout_centerHorizontal="true" />
</RelativeLayout>
When i click on the back button in the action bar the app crashes because the parent view is executing the onCreate which is calling a Firebase function:
// Get the Pool Info
poolReference = mFirebaseDatabase.getReference("PICKEMPOOLS").child(poolID);
and poolID
is null.
Question, why does this back
button trigger the OnCreate function, but if I press the back button on the Android Navigation is just dismisses the screen and goes to the previous view?