1, in this week's work, this problem let me struggle for a long time, ask Niang do not know, on the Android developer website seems to enter the word sea, turned down on a Google, or there is no good answer.
2, later got a related apk, the study found that the original with the line control ear captain on time, out of Baidu voice search should be a principle (there is installed Baidu Mobile phone client).
3, the main two action can achieve long-press operation, and similar to the effect of the background service (if the interface is displayed, the direct longpress can be processed):
Insert the following code under an activity in manifest
<Intent-filterandroid:priority= "2147483647"> <ActionAndroid:name= "Android.speech.action.WEB_SEARCH" /> <categoryAndroid:name= "Android.intent.category.DEFAULT" /> </Intent-filter> <Intent-filterandroid:priority= "2147483647"> <ActionAndroid:name= "Android.speech.action.VOICE_SEARCH_HANDS_FREE" /> <categoryAndroid:name= "Android.intent.category.DEFAULT" /> </Intent-filter>
4, of course, the activity of the dialog style can be arbitrary, such as to make a frame interface size style or completely transparent style (after performing the corresponding operation in OnStart and finish, similar to a look at
Missing service effect, and will not be due to the main program by the background to clean up and receive no response, when chatting with a colleague, he said can engage in a candid, this ...
5, the above code is tight for Android4.1 and above system (because the long-press operation of the line-controlled headset is reserved by Google as a voice search), Android4.1 the following versions only need to respond to a call Media_button
Services, the time to calculate down and up can handle growth by operation.
Android Line control headset by event