诱捕日历更改广播接收器



如果日历更改,我想接收广播。如果在日历应用程序中本地更改日历,则以下代码有效。我希望的是,如果通过在线同步远程更改日历,它也会启动更改广播程序。

我的代码如下

filter = new IntentFilter(ConnectivityManager.CONNECTIVITY_ACTION);
filter.addAction(Intent.ACTION_PROVIDER_CHANGED);
filter.addDataScheme("content");
filter.addDataAuthority("com.android.calendar", null);
registerReceiver(new CalendarChangesReceiver(), filter);

类别接收器类别为

public class CalendarChangesReceiver extends BroadcastReceiver {
CalendarChanged calChanged;
public interface CalendarChanged {
void onCalendarChanged();
}
@Override
public void onReceive(Context context, Intent intent) {
calChanged = (CalendarChanged) context;
((CalendarChanged) context).onCalendarChanged();
}

提前谢谢。

如果在日历应用中本地更改日历,则以下代码有效

这将完全取决于日历应用程序。例如,日历应用程序不需要使用CalendarContract内容提供商。而且,即使对于确实使用CalendarContract的日历应用程序,它们也不需要具有触发ACTION_PROVIDER_CHANGED广播的代码。

我想要的是,如果通过在线同步远程更改日历,它也会触发更改广播

再一次,这将完全取决于日历应用程序。

最新更新