I have created my own BroadcastReceiver like so:
class BogusBroadcastReceiver: BroadcastReceiver() {
override fun onReceive(context: Context?, intent: Intent?) {
if(intent?.action == ACTION_NAME){
Log.d { "Received Broadcast!!" }
}
}
private companion object {
const val ACTION_NAME = "com.myapp.intent.BOGUS_ACTION"
}
}
And i declare it in my manifest like this:
<application
android:name=".MyApp"
android:banner="@mipmap/ic_banner"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name">
<receiver android:name=".test.BogusBroadcastReceiver" android:exported="true" android:enabled="true">
<intent-filter>
<action android:name="com.myapp.intent.BOGUS_ACTION" />
</intent-filter>
</receiver>
...
</application>
However when i try to trigger it from adb like:
adb shell am broadcast -a com.myapp.intent.BOGUS_ACTION
I get:
Broadcasting: Intent { act=com.myapp.intent.BOGUS_ACTION flg=0x400000 }
Broadcast completed: result=0
But the log line never gets printed and my BroadcastReceiver doesnt run, regardless of the app being in foreground or background.
What am i missing here?