Android 在 SearchView 中单击语音图标时查找

Android Find when the voice icon is clicked in a SearchView

绞尽脑汁,还是一筹莫展。 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).. 将不起作用。

除了扩展 SearchView 并放入我自己的点击监听器之外,还有什么方法可以让我知道用户何时点击了语音图标?

就像任何搜索一样,根据其文档,在 SearchManager.QUERY. However, for voice search, SearchManager.USER_QUERY 中找到的结果将为空:

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.