8.0 after the broadcast is registered in Androidmanifest.xml, send intent cannot receive the broadcast

Source: Internet
Author: User

8.0 after the broadcast in the Androidmanifest.xml to send intent is not received broadcast, looked at the reason, as if 8.0 to manage the system and save power specifically for the broadcast and service delivery intent the way to initiate the change, that is, the broadcast and services can not be randomly received intent, To be more precise with broadcast and service, so when creating intent, we need to specify the package name plus class name for our broadcast and service, for the exact.

Such as:

Intent Intent = new Intent (); Intent.setaction ("Com.example.adyyzjb.app"); Intent.setcomponent (New ComponentName ("Com.example.adyyzjb.broadcastdemo",                        " Com.example.adyyzjb.broadcastdemo.NetworkChangeReceiver ")); Sendbroadcast (Intent);

Androidmanifest.xml

<receiver            android:name= ". Networkchangereceiver "            android:enabled=" true "            android:exported=" true ">            <intent-filter>                <action android:name= "Com.example.adyyzjb.app"/>            </intent-filter> </receiver>

8.0 after the broadcast is registered in Androidmanifest.xml, send intent cannot receive the broadcast

Related Article

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.