mParticle / mparticle-android-sdk

mParticle SDK for Android apps
http://www.mparticle.com
Other
58 stars 62 forks source link

LocalBroadcastManager does not have custom PushAnalyticsReceiver #19

Closed akvashi closed 6 years ago

akvashi commented 6 years ago

On a Pixel 2 with Android 8.0

When trying to use a custom PushAnalyticsReceiver, the Receiver is declared in the Manifest according to the documentation.

This code is called

List<ResolveInfo> result = mContext.getPackageManager().queryBroadcastReceivers(intent, 0);
        if (result != null && result.size() > 0) {
            LocalBroadcastManager.getInstance(mContext).sendBroadcast(intent);
        }

results will have a size > 0 because the BroadcastReceiver is declared.

But sendBroadcast(intent) will not work because within that method

ArrayList<LocalBroadcastManager.ReceiverRecord> entries = (ArrayList)this.mActions.get(intent.getAction());

if(entries != null) {...}

is called but the entries are null because

LocalBroadcastManager.getInstance(mContext).registerReceiver is not called.

So LocalBroadcastManager has no knowledge of the larger BroadcastReceiver query.

Also tested on an emulator at API 19. Same results.

custom PushAnalyticsReceiver does not work.

akvashi commented 6 years ago

https://stackoverflow.com/questions/23364668/register-a-local-broadcastreceiver-in-androidmanifest-xml

samdozor commented 6 years ago

Hey @akvashi thanks for the report - we're looking into a solution here and will likely release an SDK update to address.

willpassidomo commented 6 years ago

Closing this, the issue was fixed in version 5.1.2