tags:

views:

114

answers:

1

I would like to start MyActivity class when the user clicks on the search button on the handset.

Are there any strategies you can suggest for this? Any code examples would be very useful.

+2  A: 

There are two places you can consider:

  • in an activity, you should implement onKeyUp(int keyCode, KeyEvent event), and check keyCode == KeyEvent.KEYCODE_SEARCH
  • from the home screen (from Android 1.6 on), you can use the SearchManager to extend the Quick Search Box.
  • from the home screen (for Android 1.5), there is a searchable.xml API which can be exposed by using an android.intent.action.SEARCH intent-filter. This is forwards compatible, so is probably better if you are constrained to this version of the API. There is a compare/contrast document.

This is probably not what you're looking for directly, but I think should help solve the problem you're trying to solve.

jamesh