Android Find when the voice icon is clicked in a SearchView

时间:2016-07-11 20:15:31

标签: android searchview

I have been wracking my brains but have come up short. https://developer.android.com/training/search/setup.html I am trying to figure out how to find out when the user has clicked on a voice button or for that matter what the user has said. This is independent of what the user types on a searchview. So, the https://developer.android.com/reference/android/widget/SearchView.html#setOnSearchClickListener(android.view.View.OnClickListener).. will not work.

Other than extending the SearchView and putting in my own click listener is there a way for me to find out when the user has clicked on the voice icon?

1 个答案:

答案 0 :(得分:1)

Just like any search, the result is found in SearchManager.QUERY. However, for voice search, SearchManager.USER_QUERY will be empty as per its documentation:

Intent extra data key: Use this key with content.Intent.getStringExtra() to obtain the query string typed in by the user. This may be different from the value of QUERY if the intent is the result of selecting a suggestion. In that case, QUERY will contain the value of SUGGEST_COLUMN_QUERY for the suggestion, and USER_QUERY will contain the string typed by the user.

相关问题