Monitor headset removal broadcast delay ACTION_HEADSET_PLUG broadcast delay

Source: Internet
Author: User

Problem Description:

Listening system broadcast Action_headset_plug, the headset pauses playback when unplugged, however, there is a delay in actual processing, the headset unplugged does not immediately pause playback, but delayed a few seconds before pausing

Workaround:

Monitor the audiomanager.action_audio_becoming_noisy to solve the problem of this delay

 Public classEarphonereceiver extends Broadcastreceiver {@Override Public voidOnReceive (Context context, Intent Intent) {//if (intent.getaction (). Equals (Intent.action_headset_plug)) {          if(Intent.getaction (). Equals (Audiomanager.action_audio_becoming_noisy)) {//Handling Events          }    }}   Private voidRegisterearphonereceiver () {Earphonereceiver=NewEarphonereceiver (); Intentfilter Filter=NewIntentfilter (audiomanager.action_audio_becoming_noisy);//filter.addaction ("Android.intent.action.HEADSET_PLUG");Registerreceiver (Earphonereceiver,filter); }

Cons: No headphone insertion Event detected

Reference Blog: http://stackoverflow.com/questions/4124368/action-headset-plug-broadcast-delay/4267213#4267213

http://blog.csdn.net/mu399/article/details/38516039

Monitor headset removal broadcast delay ACTION_HEADSET_PLUG broadcast delay

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.