The following sections discuss the various features that you can add to your app with the Android SDK:
Integrate In-App Search¶
The Yahoo Search SDK provides an activity that handles the whole search UI experience. Start the activity with the following code:
SearchActivity.IntentBuilder intentBuilder = new SearchActivity.IntentBuilder(); Intent i = intentBuilder.buildIntent(this); startActivity(i);
You can also provide a predefined query. Search results will be shown as soon as the activity starts. Simply call the corresponding method on the builder:
SearchActivity.IntentBuilder builder = new SearchActivity.IntentBuilder(); builder.setQueryString("yahoo"); Intent i = builder.buildIntent(context); startActivity(i);
By default Web, Image and Video tabs are shown but that can disabled as below:
SearchActivity.IntentBuilder builder = new SearchActivity.IntentBuilder(); //To diable image vertical builder.enableImageSearch(false); //To diable video vertical builder.enableVideoSearch(false); Intent i = builder.buildIntent(context); startActivity(i);
- The Web vertical cannot be disabled.
If you only want to show search suggestions (not search results), the Search SDK
provides the “Search Suggest” launch state in which the query is prefilled on the
SearchBar and search suggestions are shown accordingly. Simply call the
SearchActivity.IntentBuilder builder = new SearchActivity.IntentBuilder(); builder.setQueryString(query); builder.launchWithSuggestions(true); Intent i = builder.buildIntent(context); startActivity(i);
Show App and Contact Suggestions¶
In addition to keyword search suggestions, you can enable local suggestions for apps and contacts on your phone.
To enable apps suggestions, call the
To enable apps suggestions, call the
Show Trending Search Suggestions¶
SearchActivity shows trending sugggestions when the query field is empty or
when the user clears the searchbar text. These suggestions are similar to the
ones shown on the Yahoo home page.
The trending search suggestion will be shown if the APP_ID is set using
SearchSDKSettings.Builder builder = new SearchSDKSettings.Builder(APP_HSPART, APP_HSIMP); builder.setAppId(APP_ID);
Type tag for YHS experimentation¶
Developers can perform experiments, or segment traffic and revenue between different entry points within their apps. If specified, the TYPE_TAG attribute will associate corresponding search traffic and revenue with the desired label, which can then be accessed by Yahoo Partner Managers.
SearchActivity.IntentBuilder builder = new SearchActivity.IntentBuilder(); builder.setTypeTag("TYPE_TAG"); Intent i = builder.buildIntent(context); startActivity(i);
Show Search History¶
In addition to trending suggestions, users will see the search history when the query field is empty. Search history is enabled by default.
To change the number of search history items to be shown,
The number of history items should be greater or equals than 0. An
IllegalArgumentException will be thrown otherwise. “Show All History” option
is available below set number of history items. On tap of this label you can see
maximum of hundred history items.
Integrate native ads¶
The Search SDK can display Gemini native ads within the Image vertical search interface. To enable proper revenue attribution, set your Flurry API key using
For more information on registering with Flurry to enable Gemini ads, refer to the Get Started section to create your API key.
You will also need to create an ad space and define your ad space name which will be passed in the API as below.
SearchSDKSettings.Builder builder = new SearchSDKSettings.Builder(#YOUR_DEV_APPID); builder.setupFlurryAds(#YOUR_FLURRY_API_KEY, #YOUR_AD_SPACE_NAME);