Android O - android.intent.action.PROVIDER_CHANGED 受 BroadcastRecevier 限制的影响?

Android O - android.intent.action.PROVIDER_CHANGED affected by BroadcastRecevier limitations?

在阅读新的 Android O 限制时,我注意到 Google 开发人员限制了清单中 BroadcastReceivers 的使用。他们使用术语隐式和显式 BroadcastReceivers,但我不太明白它们的确切含义。例如,我有一个应用程序使用 android.intent.action.PROVIDER_CHANGED 广播监听日历中的变化:

<receiver
    android:name=".receivers.CalendarReceiver">
    <intent-filter>
        <action android:name="android.intent.action.PROVIDER_CHANGED"/>

        <data android:scheme="content"/>
        <data android:host="com.android.calendar"/>
    </intent-filter>
</receiver>

当应用程序定位 Android O 时,此接收器是否会受到新限制的影响?

谢谢。

They use the term implicit and explicit BroadcastReceivers, but I can't quite figure out what they mean exactly

隐式广播是隐式 Intent(例如 sendBroadcast(new Intent(Intent.ACTION_PROVIDER_CHANGED)))的广播。显式广播是显式 Intent(例如 sendBroadcast(new Intent(this, WhyAreYouDoingThisReceiver.class)))的广播。

Would this receiver be affected by the new limitations when the app would target Android O?

这完全取决于发件人。

在 Android 7.0 中,日历提供程序使用此代码发送该广播:

private void doSendUpdateNotification() {
    Intent intent = new Intent(Intent.ACTION_PROVIDER_CHANGED,
            CalendarContract.CONTENT_URI);
    intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING);
    if (Log.isLoggable(TAG, Log.INFO)) {
        Log.i(TAG, "Sending notification intent: " + intent);
    }
    mContext.sendBroadcast(intent, null);
}

这是隐式广播。如果日历提供商在 Android O 上没有更改,您将无法再收听清单中的广播。您的解决方法是使用 JobScheduler,并在 JobInfo.Builder.

上通过 addContentTriggerUri() 设置作业来监视您想要的 Uri