I'm testing getting broadcast events on updating my app.
<receiver android:name=".UpdNotifyReceiver" android:enabled="true" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.MY_PACKAGE_REPLACED" />
<action android:name="android.intent.action.PACKAGE_REPLACED" />
<data android:scheme="package" />
</intent-filter>
</receiver>
class UpdNotifyReceiver : BroadcastReceiver() {
override fun onReceive(context: Context, intent: Intent) {
Log.d("info", "0 - from receiver")
if ( intent.action == Intent.ACTION_PACKAGE_REPLACED ) {
Log.d("info", "1 - from ACTION_PACKAGE_REPLACED")
}
if ( intent.action == Intent.ACTION_MY_PACKAGE_REPLACED ) {
Log.d("info", "2 - from ACTION_MY_PACKAGE_REPLACED")
}
}
}
It's working ONLY on the emulator in Android Studio, but on a real device - does not work. Why and how can I fix it?