O'Reilly logo

Xamarin Mobile Development for Android Cookbook by Matthew Leibowitz

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Integrating app searchability

Many apps work with collections of data, and users search through that data in order to find what they are looking for. Android has several search mechanisms that are integrated with the OS.

How to do it...

Integrating search into our app is very easy, only requiring a search activity and a few attributes on the activities:

  1. In order to handle searching, our app has to have an activity that will handle search intents:
    public class SearchActivity : Activity { protected override void OnCreate(Bundle bundle) { ... HandleIntent(Intent); } protected override void OnNewIntent(Intent intent) { HandleIntent(intent); } private void HandleIntent(Intent intent) { if (intent.Action == Intent.ActionSearch) { string query = intent.GetStringExtra(SearchManager.Query); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required