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