Disable home and back buttons in android - android

I'm doing an appication under phonegap (more specific in android). How can I disable the home, menu and back buttons in the screen, the idea is when i press any of the buttons, show a verification dialog, if the answer is correct, close the app. When i assign the function button doesn't show the dialog

For the home menu remove the onCreateOptionsMenu() function and also you wouldn't need the onOptionsItemSelected() function, so to hide the menu remove these two.
For the back buttons there are two of them:
The hard button in device that navigates in the app until it hits the main activity then pops out of the app, can be controlled by overriding this method onBackPressed()
And the one in the action bar that navigates all inside the app itself but never pops the user out of the app, can be set by setDisplayHomeAsUpEnabled() which takes a Boolean true to make it working, false to disable it.

Related

react native picker - doesn't hide when android back button pressed

I have a listener on the whole app for the back button press event in android to override the default behaviour of back button(exit the app).
Also in some component i have override it too if i want the back button to be disabled or do something else.
The problem is when i open a react-native-picker, the picker stays on the screen ignoring the back button press.
I want it to first close (on the first back button press) and only then do what the higher component ordered to do when back button is pressed.
so i can't override the the higher component back button handling
i thought maybe to add the picker as a screen in the navigator and instead of planting it as a component, navigate to it, so it will be added to the stack navigator.
then by default it will first pop it of the stack when pressing back.
how can i add the picker component as a screen to navigate to, or is there a better way to do that?
By default the back behavior collapses or closes the picker on Android (depending on the mode you have chosen). You can see a working example here.

How to make a backpressed action for navigating to the previous fragment in activity that implement bottom navbar?

I wanna make an application that has multiple screens (screen1, screen2, and screen3), and for navigating between screens I wanna use bottom navigation bar. I wanna make it like Instagram app that can navigate back to the previous screen when the back button is pressed. I have made an app with navbar but when I press the back button the application is closed directly even after I navigate to other screen.
Override the onBackPressed() method of your activity, and write back button logic on it.

Clicking on soft home button in navigation bar also triggers underlying click listener for a view

Some newer Android devices have removed the hard Home Button and replaced it with a soft pop up navigation bar at the bottom of the screen that appears when the user swipes up. I've found that the Home Button can also be accessed by hard pressing (not just long clicking, kind of like iOS force touch) the area where the Home Button would appear if navigation bar is visible. This action triggers an onClick event within the current application before navigating to the device home screen. How can I prevent the onClick event within the application?
You can see in the image below how the navigation bar Home Button overlays the app button. Thanks for any help, I feel like i'm missing something really obvious.

How to stop my app from exiting when back/home button button is pressed?

I am making an app exclusive for the tablet it was installed to. I wanted to put a restriction so that when the back button or home button is pressed the user will be prompted to enter a password and if the password is correct application be allowed to exit.
Overriding the back button is pretty easy, just override Activity.onBackPressed() to do whatever you want. Don't call super() or it will close the Activity!
Overriding the home button is more problematic. The only way to do so is to make your app a launcher. Then press home and select your app as the default launcher.
I'm not sure that this could be a good idea. You're "blocking" the user in this way. You can probably override the back button but you will not be able to override the home button (without making the app a launcher).
I did a sort of "kiosk" application and I had the same requirements. I ended up rooting the devices and using this Hide Bar application. The user was not able to go back, and the administrator had a button to enter, with a password, into the "admin panel". In this admin panel you can push a button to go to the launcher. From there you can, with a widget included into the Hide Bar app, restore the back and home buttons.
http://developer.android.com/reference/android/app/admin/DevicePolicyManager.html
May be this can help you for setting the passoward.

options menu does not come up after back button press android

I have an android application where I want to display a LinearLayout when user clicks on options button(I am setting the linear layout's visibility to visible in onCreateOptionsMenu) and make it invisilble when user clicks on back button.
This works fine when I press the option button and then the back button-the view comes up and then goes away respectively.
The problem is when I press the option button again, the linearlayout does not show even though the visibility is being set to visible.
However, log tells me that the methos onCreateOptionsMenu is entered.
Why would this happen?
onCreateOptionsMenu is called only once per activity. In your case you have to code in onPrepareOptionsMenu. This will be called every time the user presses menu key.
Why do you want do this? For android users relevant reaction for menu button is option menu.
What about question, try use View.bringToFront() - it will bring view in front of all views of the same parent.

Categories

Resources