I've implemented a ContentProvider to add custom suggestions to my applications Quick Search Box. It works great within my app. However I also included it into the global search and it works different there. Whenever I start a search in the global search and I select one of my suggestions, this suggestion is saved and presented the next time I open the global search. What I don't like is that my current suggestions are below the ones I clicked before.
Is there a way to disable this behavior?
I am currently thinking of integrating recent suggestions in my ContentProvider to provide both - recent and custom suggestions. Though I am afraid this will result in having the same suggestions twice - first from the global search and then from my ContentProvider...
Any advice?
I think you could try to create a custom SearchRecentSuggestionsProvider as described here.
From in there, simply return an empty cursor or null.
To answer my own question, it is possible by providing the SUGGEST_NEVER_MAKE_SHORTCUT value in the SUGGEST_COLUMN_SHORTCUT_ID column.
As usual this is described in the Android developer documentation here.
Related
I need to give a search box in my android app. As the user starts typing in the search text, I need to show him relevant suggestions. (As we see in the google-search widget on the home screen. If we see from the logs, com.android.quicksearchbox/.SearchActivity is started with android.search.action.GLOBAL_SEARCH intent and it searches in following: corpora:[web, apps, com.android.contacts/.activities.PeopleActivity]).
Only thing is I need the suggestions to be displayed from the web & my application DB.
Any idea how to implement this ? Do I need to implement my own SuggestionsProvider or can I directly use the native implementation? If so, how?
I think i figure it out myself.
Went through Searchable Dictionary code & QuickSearchBox code in android source.
Need two start 2 activities in a background thread. One will search for the search-term in my DB & other will search the same in Google. All the results will be seen in the suggestion list.
Google Suggest API provides suggestions as the user enters the text.
One year ago I developed a sync adapter for Android.
At that time it wasn't possible to show a custom activity or to customize the standard activity to edit a contact.
The result was that, although it was possible to configure the synch adapter in a such a way that the added contacts where editable, to edit a contact was not really feasible, unless the custom contacts were the same as the normal ones.
Is it still like that? Did google fix the problem?
See for a reference:
http://groups.google.com/group/android-developers/msg/86d4d895e88a5ebb
I found this: http://groups.google.com/group/android-developers/msg/85f9304dfcc4e284
but it does not say where to find the documentation
There is a workaround catching an intent to launch your own activity.
you need to modify a bit the following example but it works very well (on 2.3.x and 4.0.X) for me for insertion.
https://stackoverflow.com/a/11153652/1195001
If you using Twitter for Android you can see that clicking on phone's hard search button brings fully customized quick search-like control. Now I'm not saying that it IS stock Android customized quick search but how would one build something like that?
I want quick search box behavior but I also want add some additional selectors (think Firefox search where on the left there's a dropdown to select search engine)
I suspect that clicking search brings another activity that just looks like a quick search. Now I know how to trigger search activity from the quick search but how to intercept quick box call and display your activity instead?
Where would I start with something like that? Any hints and pointers will be greatly appreciated
With no screenshot, I can't help terribly much, since I don't use the official Twitter app (I'm a Seesmic guy), so I don't quite know what you are talking about.
You can override onSearchRequested() to get control when the user requests a search in your activity. Return true to say you're handling the search yourself. Along the way, pop up whatever you like to allow the user to do a search.
I am making an Android app. I have a list of items displaying. I am looking to create a popup menu just like the one that pops up when you tap the avatar of a contact in the contact list. I have tried looking through the Android reference but can not find it.
Has anyone created one of these popup menus? A link to the reference or a code sample is fine.
Screenshot of menu:
http://www.youchoob.org/pics/popup.jpg
What you are describing is called a 'Quick Action'. This is actually a user interface pattern - there isn't an existing widget or anything in the API for this. They discussed it at Google IO (See in this video here, at the 15:40 mark), and also there has been some discussion on how to implement it on stack overflow, specifically this question. If you start digging around (now that you know the name of what you are looking for) you might find more.
you can find "QuickAction" widget in
https://github.com/cyrilmottier/GreenDroid
below is a demo activity
https://github.com/cyrilmottier/GreenDroid/blob/master/GDCatalog/src/com/cyrilmottier/android/gdcatalog/QuickActionActivity.java
Please find the code OR framework from here :
http://www.londatiga.net/it/how-to-create-quickaction-dialog-in-android/
The source code for the contacts is open source. You should look around here and see if you can find it.
https://android.googlesource.com/platform/packages/apps/Contacts
I'm looking now if I find it I will edit.
I have a ListView, as well as a refreshListFromDB(String searchKeywords) method which updates the adapter.
I'd like to implement search, where pressing the search key on my device will pop up the standard search box (and on-screen keyboard if required), and pass the result (onKeyDown) to refreshListFromDB() - or is this considered bad UI design?
Search is a complex beast, so can anyone recommend any bare-bones examples? I don't want to use global QSB, as it's not relavent for my type of app. Do I really need to get into Intents, searchable XML, new activities, content providers etc?
I'd like to implement search, where
pressing the search key on my device
will pop up the standard search box
(and on-screen keyboard if required),
and pass the result (onKeyDown) to
refreshListFromDB() - or is this
considered bad UI design?
I don't know about "bad UI design", but the standard search box doesn't do what you say you want it to do.
Search is a complex beast, so can
anyone recommend any bare-bones
examples?
I used to have a bare-bones example, but that was before QSB, which added another pile of bones on top of the bones I had. You can still look at the larger pile of bones here, and the pieces you seek are described in (ahem) a book.
Do I really need to get into Intents,
searchable XML, new activities,
content providers etc?
To use the "standard search box", you need the first two in your list, and possibly the third depending on how you want to do it. I have both reused existing activities and created new ones in my search experiments. You will not need a content provider, though.
You could also have a look at the Searchable Dictionary Sample Application that comes with the SDK, although I think this does integrate with the Quick Search Box.