質問

First some background.

In my edit item activity I have added search functionality to change of one of the item's data fields. (Its manufacturer and make). Since the user can select from quite a large amount of items, we have decided to use search with suggestions to change the manufacturer/model.

Using the normal Android search, from the edit activity I can override the onSearchRequested() method and add the current item's ID as part of the extra data. The actual updating of the data item, is done in the search activity. (I know, not the best idea, but my edit activity doesn't know what the user did in the search activity.)

This works fine for a simple search, but I can't seem to find a place to inject this context data (the item's id) for Search Suggestions.

I have read through the android docs and the closest I have come across is SUGGEST_COLUMN_INTENT_EXTRA_DATA column for the resultant row in my suggestion, but since my search content provider also doesn't have any context of what item I am editing, it doesn't seem like it will solve my problem. The Intent is still launched from the suggestion by the Android system, and I can't seem to get the required context info added to it.

Is this even possible given that search suggestions seems to be geared towards context-less global searches i.e. Android's quick search?

For completeness sake: we are targeting platforms less than Android 3.0, so the functionality of SearchView is not available.

役に立ちましたか?

解決

Good news: the Intent that the suggestions launch directly is the same one that the activity sets up in the call to 'onSearchRequested()'. Any context info can be set there. Can anyone find a reference to this in the docs?

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top