ANDROIDFM Module Learning five closing the FM process

Source: Internet
Author: User

A while ago briefly described some of the FM open, recording and search process, analysis of the various types of source code, the next is to close the FM, the study of the FM module is over, I hope that the finishing can be in the FM in the understanding of some help, If you have encountered a problem or bug when modifying the upper layer code of the FM module, you can leave a message and we will deal with it together.

FM off in two ways, one is to unplug the headset, FM off, and the other is to press the Close button.

See the first way:

Flow chart:

In the Fmradioservice class, the user directly pulls out the ear to receive one, the headset pulls out the broadcast intent.action_headset_plug when the headset is unplugged mheadsetplugged = (Intent.getintextra (" State ", 0) = = 1); Take 0. Then use Mhandler.post (Mheadsetpluginhandler) to refresh the headset status. Call Fmoff (); Fmoff () Call the STOPFM () method to close the FM received signal device and call Fmrecevice's disable () method to turn off the FM device. Call mcallbacks.ondisabled (); Ifmradioservicecallbacks in ondisabled () sends a handler,mhandler.post (mRadioDisabled); To turn off Fmradio UI state, etc.

Cleanuptimeouthandler (); Endsleeptimer (); stoprecording (); Cancelsearch (); Enableradioonoffui (false);

Next, look at the second way:

Flow chart:

When the FM-click-Close button is manually turned off in the Fmradio class interface, the Monoffbutton listener can be manually closed during the callback method Mturnonoffclicklistener when FM is played, by sending handler Mdisableradiotask callback method. The Disableradio () method is called in Mdisableradiotask. The Fmoff () in Fmradioservice is called through a reference to the class that inherits the stub class, (Mservice.fmoff (),), Fmoff () calls the STOPFM () method to close the FM received signal device, and calls Fmrecevice disable ( ) method to turn off the FM device, call Enableradioonoffui (), and change the Fmradio UI state.



ANDROIDFM Module Learning five closing the FM process

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.