Disable the search button in Android
<p>I have a dialog in an Android app that I don't want the user to be able to cancel.  Using <code>.setCancelable(false)</code> disables the back button, but pressing the search button still cancels the dialog.  I saw <a href="http://stackoverflow.com/questions/7021739/disable-the-search-button-quick-search-box-in-android/7023495#comment12447188_7023495">this question</a> which told me that I should include</p>

<pre><code>public boolean onSearchRequested() {
    return false;
}
</code></pre>

<p>But I'm still able to cancel the dialog with the search button.  Here's my code:</p>

<pre><code>public class TestActivity extends Activity {
    /** Called when the activity is first created. */
    @Override
        public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        showDialog(0);
    }

    public boolean onSearchRequested() {
        return false;
    }

    protected Dialog onCreateDialog(int id) {
        final AlertDialog.Builder builder = new AlertDialog.Builder(this);
        builder.setMessage("Message")
               .setCancelable(false)
               .setPositiveButton("Ok", new DialogInterface.OnClickListener() {
                   public void onClick(DialogInterface dialog, int id) {
                       // nothing
                   }
               });
         return builder.create();
    }
}
</code></pre>
