简体   繁体   中英

onReceive Broadcast on 8.1.0

I have a working broadcast on a physical Android 8.0 (API 26) device as well as an 8.0 emulator. It does not work on Android 8.1.0 emulator or physical device.

I also tried registering the receiver but still not working.

Intent intent=new Intent(this, MainActivity.class);
intent.setAction("com.my.receiver");
intent.addFlags(Intent.FLAG_INCLUDE_STOPPED_PACKAGES);
sendBroadcast(intent);

xml

<receiver
    android:name=".Helpers.MyReceiver"
    android:enabled="true"
    android:exported="true">
    <intent-filter>
        <action android:name="com.my.receiver"/>
        <action android:name="android.intent.action.BOOT_COMPLETED"/>
    </intent-filter>
</receiver>
Intent intent=new Intent(this, MainActivity.class);

The Java class that you specify here is MainActivity .

android:name=".Helpers.MyReceiver"

The Java class that you specify here is .Helpers.MyReceiver .

These are not the same. This receiver will not receive this broadcast on any version of Android, let alone Android 8.1.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM