<" /> <" /> <"/>

MY_PACKAGE_REPLACED and PACKAGE_REPLACED actions don't start on the real device, but on the emulator - ok

139 Views Asked by At

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?

0

There are 0 best solutions below