Android Line control headset by event

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.