Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

android app search button

I've been trying to make my app implement the built in quick search, similar to how it is done in ApiDemos' "app/search/invoke search". I have tried everything from trying to follow different examples, to copying the code exactly as it is in ApiDemos.

All I've found for the former have been concerned with older versions of the SDK, and simply not worked. As for the stuff that I can actually run and see working in ApiDemos, I've tried copying the following

com.example.android.apis.app.SearchInvoke.java
com.example.android.apis.app.SearchQueryResults.java
com.example.android.apis.app.SearchSuggestionSampleProvider.java

res/layout/search_invoke.xml
res/layout/search_query_results.xml
res/values/arrays.xml
res/values/strings.xml
res/xml/searchable.xml

... and everything under "Search Samples" in AndroidManifest.xml

This copying gets me a view that looks exactly like the one I'm facing when running ApiDemos, but when I click the search button, in the quick search box, Android always just opens up a browser window, with Google search results for the given query. I simply cannot find the critical component in ApiDemos that tells android that I want to use my own custom code for handling the search request.

I would really appreciate some help in this matter. Both documentation and other online resources seem very lacking when it comes to this.

Thanks.

like image 333
David Hedlund Avatar asked Oct 18 '09 13:10

David Hedlund


People also ask

Where is the search button on Android phone?

Whether you have Samsung or LG or Pixel Android phones, the Google Search bar will be on the home screen of your Android mobile phone. However, you may accidentally remove this Google Search bar from Home screen or deleted the App.

What is Android app search?

AppSearch is a high-performance on-device search solution for managing locally stored, structured data. It contains APIs for indexing data and retrieving data using full-text search. Applications can use AppSearch to offer custom in-app search capabilities, allowing users to search for content even while offline.


2 Answers

For reference, four months (and god knows how many attempts) later, I've found the part of the documentation I've missed out on, that had the whole search box behave fire up browser search results, instead of passing them to my own activity. It all comes down to a little notice found here:

Note that all user-visible strings must be provided in the form of "@string" references. Hard-coded strings, which cannot be localized, will not work properly in search metadata.

like image 182
David Hedlund Avatar answered Sep 18 '22 13:09

David Hedlund


Try reading this first. If that does not help, you can try looking at the search example from one of my books -- that example integrates with the Quick Search Box, and perhaps it will give you more clues.

like image 23
CommonsWare Avatar answered Sep 21 '22 13:09

CommonsWare