<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时,此接收器是否会受到新限制的影响?
谢谢。
答案 0 :(得分:5)
他们使用术语隐式和显式BroadcastReceivers,但我无法弄清楚它们的确切含义
隐式广播是隐式Intent
的广播(例如,sendBroadcast(new Intent(Intent.ACTION_PROVIDER_CHANGED))
)。显式广播是明确Intent
的广播(例如,sendBroadcast(new Intent(this, WhyAreYouDoingThisReceiver.class))
)。
当应用程序针对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
,并将作业集设置为通过Uri
上的addContentTriggerUri()
来监控您所需的JobInfo.Builder
。