2

I'm developing an application right now and I need to disable the quick-search-box as somehow it dismisses my dialog boxes that request info to keep people who are not supposed to be using my application out [its in development, and its on the market - it makes it much easier to keep people up to date]. Listeners for all types of dismissing dialogs are never triggered - and I don't know why. I've looked everywhere and I get no result on how to disable this. (2.1 and up). How to disable QSB..? was a good start, but it doesn't work. I don't know why google insists I use this... I have absolutely no need for this in my application. How can I go about fixing this... or do I have to try another sort of DRM?

Community
  • 1
  • 1
Mgamerz
  • 2,872
  • 2
  • 27
  • 48
  • Did you try to intercept the search-button? Why do you want to lock people out of your app? And what does 'somehow it dismisses my dialog boxes'? Dialogs work fine in Android. – marsbear Aug 11 '11 at 06:37
  • My app is on the market, but it is not finished - I only have it on the market because it is a lot easier to update everyone at the same time that way. I make users pick a date and if the date doesn't match, the app kills itself. However, if they press search, the QSB comes up and it somehow dismisses the dialog without triggering any of the dialog listeners that listen when it closes. – Mgamerz Aug 11 '11 at 06:44

2 Answers2

5

You can block the search on your activity or dialog by implementing this and returning false:

public boolean onSearchRequested() {
    return false;
}

UPDATE:
Code works on dialogs, too

marsbear
  • 1,459
  • 10
  • 23
  • I tried that, but sadly it doesn't work... At least not on 2.1. I haven't had a chance to test on 2.3. – Mgamerz Aug 11 '11 at 15:05
  • How does it not work? Do you get an exception? What dialog did you use? Did you implement that function on the activity that opens the dialog? – marsbear Aug 11 '11 at 15:38
  • I did implement that... now now the dialog boxes just go away. (It seems eclair handles this slightly differently, but on gingerbread it works... but the boxes still go away) – Mgamerz Aug 11 '11 at 15:39
  • You should implement the method on your dialog. – marsbear Aug 11 '11 at 15:40
  • I implemented it in both, however I am now having a huge switch problem trying to get it to show (I have 2 different dialogs)... but I'll mark your answer if it works when I get it working :) – Mgamerz Aug 11 '11 at 16:33
  • Thanks! I overrode it in the activity and the dialog. – Mgamerz Aug 11 '11 at 16:55
  • Could you explain what you mean by "implement the method on your dialog"? Where in my program do I put the code that's in your answer? Thanks! – BenH Mar 19 '12 at 22:45
  • You should have a class that represents the dialog you are showing. Please create a new Question and show the code you are using right now. If you post a link to your question here I can answer it. – marsbear Mar 21 '12 at 14:02
  • [Here it is.](http://stackoverflow.com/questions/9832381/disable-the-search-button-in-android) – BenH Mar 23 '12 at 00:07
0
  public boolean onKeyDown(int keyCode, KeyEvent event) {

                    if(keyCode==KeyEvent.KEYCODE_SEARCH  && event.getRepeatCount() == 0)
                    {
                        return true;
                    } 
                  else
                   {

                    return false;
                   }
                }

Returning true means that we are handling the Search Event.

Andro Selva
  • 53,910
  • 52
  • 193
  • 240