How can I tell if the search string returned from SearchManager is a result of a VoiceSearch?
In my searchable.xml, I have:
android:voiceSearchMode="showVoiceSearchButton|launchRecognizer"
I get the search string returned SearchManager like so:
if (Intent.ACTION_SEARCH.equals(action)) {
searchString = intent.getStringExtra(SearchManager.QUERY);
}
Is there any way to get from the intent whether the search string came from the keyboard, or as a result of voice search and the speech Recognizer?
I know I can put entities like:
<actionkey android:keycode="KEYCODE_SEARCH" android:queryActionMsg="search"/> <actionkey android:keycode="KEYCODE_ENTER" android:queryActionMsg="enter"/>
in my searchable.xml file, and then use intent.getIntExtra(SearchManager.ACTION_KEY,-999) to see if the search started because the user hit the Enter key on the keyboard, or the hardware Search button, but I don't see how to detect that the search was started from the "microphone" icon button, or the "search" icon button in the search bar.
(In the case of a voice search, I need to echo the text back to the user while I do a further web lookup. For a text search, echoing what the user just typed is redundant.)
How can I tell the difference?
Asked by: Julian268 | Posted: 25-01-2022
Answer 1
Answering my own question: if I just type a query, the QUERY and the USER_QUERY both return the typed text. If I speak it, the USER_QUERY is null.
Answered by: Edgar970 | Posted: 26-02-2022Answer 2
I'm guessing that the voice input is just an input method editor (IME), and you aren't going to be able to get any info on what IME was used to enter the text.
Answered by: Adrian715 | Posted: 26-02-2022Similar questions
callback - Get result from SearchManager activity to Main Activity in android
Use Case:
Activity A is main activity. Whereas Activity B is SearcActivity (SearchManager). Activity B is ListActivity, so whatever result comes, result is displayed in the list. Once user clicks on the list, I want to get that list selected item to be returned to ActivityA.
What I did?
I could call SearchActivity on button using "onSearchRequested()". In ActivityB, I am displaying searchresult via "setListAdapter(...
android: how to position SearchManager somewhere around 60dip from top?
I have implemented android's searchmanager using onSearchRequested(). This works fine but it shows itself on top of the page. How can I adjust the layout to just around 60dip from top?
many thanks,
android - How to use SearchManager in local app?
Hi all,
I have a activity which have a listview. I need to refine the listview by people's inputs.
I have tried to implement it by following the topic http://developer.android.com/guide/topics/search/search-dialog.html. but the problem is that I can only get the default searchbar (which can sear...
android - SearchManager functionality - Icon on the left of the search bar
I am trying to use the SearchManager - it works ok but the icon I am specifying in the searchable.xml is not appearing on the bar instead the default "green android" button is showing up. I removed the icon line from searchable.xml but the "green android" button still shows up. What am I doing wrong here?
android:searchSuggestAuthority="xyz"
android:searchSuggestIntentAction="...
java - How to dismiss SearchManager after search
how I am trying to dismiss the SearchManager in an android application after I finish fetching data, how I can do that?
for now I am touching the list view to hide the search bar and the keyboard.
http://www.ideasandroid.com/android/sdk/docs/images/search/search-suggest-custo...
android - SearchManager - adding custom suggestions
I've read all of the documentation online about building search interfaces and adding custom suggestions... but I'm still unclear on how this works. The documentation says that I must "Build a table (such as in an SQLiteDatabase) for your suggestions and format the table with required columns". I'm assuming the system will eventually fill this table with the appropriate suggestions on its own... but which process/class is ...
How to clear values of SearchManager after providing the results in Android?
Is there a way to clear the input values of the default search manager that is used in Android?
I need to clear off the search query that is being typed in the editbox after the results have been displayed!
search - SearchManager Android 4.x issue
I have been facing a problem using Search Manager with android 4.x sdk version.
I'm getting ClassCastException at this line
String sSearch = intent.getStringExtra(SearchManager.USER_QUERY);
Exception details:
java.lang.ClassCastException: android.text.SpannableString cannot be
cast to java.lang.String
The issue has been reported at
Android searchmanager triggersearch giving null pointer exception
Here is the code getting searchmanagerinstance and calling trigger search:
The same works fine with startsearch call not with triggersearch
String searchQuery = "dollar in rupees\n";
SearchManager s = (SearchManager) this.getSystemService(Context.SEARCH_SERVICE);
// s.startSearch(searchQuery, false , null, null, true);
s.triggerSearch(searchQuery, new ComponentName(getApplicationContext().getPackageName(), ...
android - Getting Result from Activity Started with SearchManager
I am following this relatively simple tutorial on how to manually start a SearchableActivity so that I can get a result back from it.
He is basically setting up the base Activity (Activity A) as the searchable activity (in the manife...
Still can't find your answer? Check out these communities...
Android Google Support | Android Community | Android Community (Facebook) | Dev.io Android