3

I am trying to make a restricted android launcher for some people. The key features that I am trying is

  • Giving Access to Selected App to be laucnched.
  • Disable the button that allows to show user to show every app installed on the phone
  • Disable physical button (menu) in order to restrict user to go in to "Settings" menu of Android.

If these features are possible, it would be great if you could link me any examples or explain how to do this.

Thank you.

gustavohenke
  • 40,997
  • 14
  • 121
  • 129
Jae Park
  • 621
  • 4
  • 13
  • 27

3 Answers3

6
@Override
public boolean onPrepareOptionsMenu (Menu menu) {
    return false;
}

Documentation says:

You must return true for the menu to be displayed; if you return false it will not be shown.

Chintan Soni
  • 24,761
  • 25
  • 106
  • 174
  • 1
    This disables all things menu related. I want the overflow menu button in the action bar, but just want to disable the hardware menu button. – user2968401 Jun 11 '15 at 23:38
  • @user2968401 For that I guess, you will need to read this post: http://stackoverflow.com/questions/9286822/how-to-force-use-of-overflow-menu-on-devices-with-menu-button – Chintan Soni Jun 12 '15 at 02:40
3

Override the onPrepareOptionsMenu

public boolean onPrepareOptionsMenu (Menu menu) {
   return false;
}
silly
  • 7,789
  • 2
  • 24
  • 37
  • If possible, it would be helpful that you could explain what this code does.. since I am not used to android coding.. thx.. – Jae Park Feb 12 '14 at 08:03
1

Check the AndroidDoc

Implement the keylistener and Override the onKeyDown method

@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
    boolean clickedPhysicalMenu = false;
    if (keyCode == KeyEvent.KEYCODE_MENU) {
        clickedPhysicalMenu = true;
    }
    return clickedPhysicalMenu;
}
Jason
  • 1,658
  • 3
  • 20
  • 51
Nambi
  • 11,944
  • 3
  • 37
  • 49
  • If possible, it would be helpful that you could explain what this code does.. since I am not used to android coding.. thx – Jae Park Feb 12 '14 at 08:04
  • 5
    This is incorrect to disable the menu key you should return true to prevent further propagation of the event see [link]https://developer.android.com/reference/android/app/Activity.html#onKeyDown(int, android.view.KeyEvent)[link] `@Override public boolean onKeyDown(int keyCode, KeyEvent event) { if (keyCode == KeyEvent.KEYCODE_MENU) { return true; } return super.onKeyDown(keyCode, event); }` – Aaron Dancygier Jan 19 '15 at 08:13