NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
11/19/15 06:00 AM (9 years ago)

Can I prevent the Back Button on Android phones to have an effect ?

Good afternoon ladies and gents, Is there a way to prevent the physical Back button on android phones to have an effect while in the app ? His default effect is to go back to the previous page but it creates some problems. I can't find where it would be. I guessed in BT_fragment but since I don't know how this button is called, I can't trace it in the code, if it is somewhere. Cheers ! Nico
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
11/19/15 07:38 AM (9 years ago)
BT_activity_host - line 535 onBackPressed ... is where the back button is handled. The above relates to Eclipse. Hopefully it is still the same in AS.
 
NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
like
11/19/15 08:48 AM (9 years ago)
You're right Krompa, it's all there. I put the whole thing between /* */ but it keeps doing the same thing. I guess by default it was what it's meant to do on the phone, which is "go back". How can I tell it to not do anything ? Cheers Nico
 
krompa
Lost but trying
Profile
Posts: 257
Reg: Jun 14, 2013
Bristol
8,820
like
11/19/15 01:33 PM (9 years ago)
How about keeping the method there, but doing nothing. So just have: @Override public void onBackPressed() { }
 
NicoRacing
Lost but trying
Profile
Posts: 78
Reg: Oct 25, 2013
Hyeres
3,680
like
11/19/15 02:25 PM (9 years ago)
It works ! Thanks a bunch Kompra !
 
Agu
Lost but trying
Profile
Posts: 98
Reg: Mar 06, 2014
GRANADA
980
like
03/02/17 11:31 AM (7 years ago)
I want to do the same...testing...
 

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.