peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
04/16/14 06:50 AM (10 years ago)

Android back button doesn't load screens from prior tabs

I have a new Android app with tabs, menu simple, and menu with image. What I'm noticing in testing is that if you move through the menus and tabs, and then start pressing the back button (the hard device back button), it will take you as far as the first screen in your active tab, and from then on it only changes the title bar (in other words, the title bar will say "Tab A", when the rest of the screen stays on "Tab B"). If you keep pressing back, it will keep loading correct title bars from your history, but the rest of the screen will stay the same. If you continue to interact with the app after that, it starts getting really weird, so it's best to quit the app and start over. I'm given to understand that Android users use the back button on their device a lot. Is anyone else having this issue?
 
Niraj
buzztouch Evangelist
Profile
Posts: 2943
Reg: Jul 11, 2012
Cerritos
37,930
like
04/16/14 08:42 AM (10 years ago)
Wow -- crazy! Maybe we should have a bug feast during lunch at The BuzzCamp!
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
04/16/14 10:12 AM (10 years ago)
Niraj, I think you might be onto something there!
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
05/12/14 11:28 AM (10 years ago)
I can't figure out anything else to do, other than just add all screens to the back stack. I was able to modify the code in BT_activity_host to add all screens to the back stack. While this isn't what you're supposed to do according to Google guidelines on handling the back button, I can't figure out how to fix, and I'm afraid the user would think something is wrong or it's broken with the way it's currently working with it just loading title bars.
 
AlanMac
Aspiring developer
Profile
Posts: 2612
Reg: Mar 05, 2012
Esher, UK
37,120
like
05/12/14 12:34 PM (10 years ago)
I did a little experiment with menus in ios and android joint apps a couple of weeks ago, trying to decide the best navigation for an app I have in mind. I concluded that in my opinion, menu tabs do not seem work very well in BT 3.0 Android. I didn't like the way they presented - can't put my finger on the detail now, but what you've described might be what I was seeing. I decided the best option is to not use them.
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
05/12/14 05:55 PM (10 years ago)
I agree with you AlanMac. The guidelines from Google just seem a little strange. These two resources: http://developer.android.com/training/implementing-navigation/temporal.html http://developer.android.com/design/patterns/navigation.html describe proper ways to provide navigation, and talk about using the Up button and the Back button. They make the following declaration: "Note: You should not add transactions to the back stack when the transaction is for horizontal navigation (such as when switching tabs)..." That seems odd. I tend to expect "Back" to take me back, no matter where it was. I checked out another app with tabs (ESPN's sport center app I think), and when you get to a home screen of a tab and hit back, it quits the app. I dunno, a little weird. Nonetheless, I'd be cool following the guidelines, but I can't figure out how to make the code do it.
 
Barata
Aspiring developer
Profile
Posts: 5
Reg: Apr 28, 2012
location unknow...
5,700
like
05/26/14 12:36 AM (10 years ago)
Hi peterj, I have exactly the same problem...could you please tell me how to modify the code in BT_activity_host to add all screens to the back stack? Thank you in advance, joao barata
 
peterj
Apple Fan
Profile
Posts: 113
Reg: Jun 19, 2011
location unknow...
6,630
like
05/27/14 04:52 AM (10 years ago)
Around line 1159, you should see the "if" loop with the comment "Tab taps should not be added to the back-stack". Comment out or delete the lines of the loop, so that just "ft.addTobackStack("itemTap"); is left. This apparently adds every screen to the back stack. I normally like to comment code out, instead of deleting it (just in case I want to do more work with it later, so I made this: if(addToBackStack != false){ ft.addToBackStack("itemTap"); }else{ //do nothing... } Look like this: //if(addToBackStack != false){ ft.addToBackStack("itemTap"); //}else{ //do nothing... //}
 
Barata
Aspiring developer
Profile
Posts: 5
Reg: Apr 28, 2012
location unknow...
5,700
like
05/27/14 11:11 AM (10 years ago)
Thank you! I will try those changes and get back to share the results! Cheers!
 
Barata
Aspiring developer
Profile
Posts: 5
Reg: Apr 28, 2012
location unknow...
5,700
like
05/28/14 06:27 AM (10 years ago)
Hi peterj, I have already changed the code according to your instructions. It really helped because navigation stopped its weird behavior, the one you mentioned in your first post. However, there is still an effect that may cause confusion to the user. Consider, for instance, I have a tabbed layout with two tabs, T1 and T2. Inside T1 there is one menu button MB1. Similarly, inside T2 there is one menu button MB2. If the user is in T1 he/she sees MB1 and if he/she changes to T2, sees MB2. However, if the user is in T1, changes to T2 and then presses back button, he/she will see MB1 (the menu buttons of T1) but (and this is the problem) the underlined tab will still be T2! So apparently the back button leads to the previous screen but not to the previous tab! This might confuse the user, so any help is welcome! Thank you in advance! João Barata
 
CMCOFFEE
Android Fan
Profile
Posts: 2017
Reg: Jan 04, 2013
Amarillo, Texas
26,670
like
07/18/15 04:20 PM (9 years ago)
thats not the back button on android.its the "home" button for android
 

Login + Screen Name Required to Post

pointerLogin to participate so you can start earning points. Once you're logged in (and have a screen name entered in your profile), you can subscribe to topics, follow users, and start learning how to make apps like the pros.