I have registered following receiver
which is not getting called in Android Oreo but works on lower version devices.
<receiver
android:name=".common.receiver.ConsultReceiver"
android:exported="false">
<intent-filter>
<action android:name="APP_STARTED" />
<action android:name="APP_STARTED_FROM_ORGANIC" />
</intent-filter>
</receiver>
Any help would be appreciated?
If your app targets API level 26 or higher, you cannot use the manifest to declare a receiver for implicit broadcasts (broadcasts that do not target your app specifically), except for a few implicit broadcasts that are exempted from that restriction. In most cases, you can use scheduled jobs instead.
In Android 8.0 and above, use the following code to check when some app is installed or uninstalled.
In general, you cannot use an implicit
Intent
(e.g., one with just an action string) for a broadcast on Android 8.0+.Your
<receiver>
is not exported. This suggests one of three things:You are using this with a
PendingIntent
, such as for aNotification
. If so, get rid of the<intent-filter>
and use an explicitIntent
(new Intent(this, ConsultReceiver.class)
) as part of creating yourPendingIntent
that points to this receiver.You are using this as part of some IPC between multiple app processes in your app. In that case, also use an explicit
Intent
.You are using this receiver purely within one process within your app. In that case, get rid of the
<receiver>
and use something else (LocalBroadcastManager
, an event bus, RxJava,LiveData
, etc.).Restrict the
Intent
to your package with setPackage.