how to disable navigation keys in android programmatically - android

how do I disable the menu, home, back and search key programmatically in android, including the vibrate when those keys are pressed.

You can't disable the home button. The back button you'll need to override onBackPressed(), and the menu button shouldn't do anything unless you assign it an action.
If you mean disable these system-wide, I'm afraid glad you can't do that.

Related

How to disable back button behavior?

I need to create a pin entry. I want the numeric keypad to be visible always. The problem is, I cannot override hardware button behavior which dismisses the keyboard. OnBackButtonPressed isn't entered when the button is pressed for dismissing the keyboard. What can I do? ()
I think that the best option for you is use an specific keyboard.
Maybe you can use this Xamarin component https://components.xamarin.com/view/TestComponent

Disable home and back buttons in 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.

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.

Cannot figure out how to make android keyboard go away, unless back button is press

I have a EditView. When some one clicks on the EditView, the only way the keywbaord will go away is if the back button id press.
I saw some apps have it so when the keyboard comes up, there is a button that says done in the lower right hand corner. When this is press the keyboard goes away.
My app does not do this, does anybody know how they did this?
Also is it possible to have the keyboard go away when the enter key is press, insrad of having it add another line of text?
You can either use TextView.setImeOptions() and pass it actionDone or use the android:imeOptions="actionDone" attribute in your layout.
To close when enter is pressed, use a custom OnEditorActionListener. However, it would probably be better to change the enter key to done as above so as to convey what action will occur.
See this SO question.

How to display menu without pressing menu button?

I have a menu that I want to appear on the screen when the app starts, without the user having to press the menu key.
What is a good way to achieve that?
Maybe Activity.openOptionsMenu() or Activity.openContextMenu?

Categories

Resources