Hi guys, I'm new to Kotlin (and coding in general) and I need help and guidance with some codes, I have created four activities on Android studio, and I am trying to use "Intent" to navigate from one activity to the other....My code worked well when moving from MainActivity to the second activity (Genderpg, but when I tried moving from the 2nd Activity to the third (AgePg02), the Emulator keeps returning me back to the Main activity.....here are images of my code...
stackoverflow 4
πΆ 7
l
Louis Gautier
05/10/2022, 7:21 AM
seems good to me. Are you sure of
btn_gender_back
and
btn_gender_continue
are not inverted in your xml ?
Also, from what I can see, I suggest you to move to ViewPager with fragment. Itβs a bit more complicated, but in the end, I will be easier to handle this kind of navigation flow
r
Ronald Wolvers
05/10/2022, 5:06 PM
Just wanted to draw attention to the existence of the
finish()
call on an activity. This will simply take the activity off of the backstack as opposed to adding a new one. If you keep making new activities you will end up with quite a lot after navigating a bit, and your app will consume less memory if you simply pop them with the call to
finish()
Ronald Wolvers
05/10/2022, 5:07 PM
Other than that looks good to me as well!
f
Fisayo
05/10/2022, 7:16 PM
Thanks @Louis Gautier and @Ronald Wolvers I will long into using the ViewPager with fragment and the finish() call in my code ππ½