-
Notifications
You must be signed in to change notification settings - Fork 249
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Send PROVIDER_CHANGED broadcast to all packages #822
Comments
The problem with Android 8 is, implicit broadcasts can no longer be sent to broadcast receivers which are registered in the Manifest of an app (see https://developer.android.com/guide/components/broadcasts). Broadcast receivers which are registered dynamically by an app running in the foreground or by a background service would still receive this broadcast, but if the app is already running, it could also use other means of getting notified when the content provider changes, like a ContentObserver. So the usefulness of this broadcast is somewhat limited. Do you register your receiver dynamically at runtime or in the Manifest file? |
It's registered dynamically. It was indeed complicated to make receiving the broadcasts work, but the problem is solved. I'd say the responsibility for making sure that the broadcasts are received should be in the listening app; OpenTasks can send the broadcast; if anyone wants to listen they can take the appropriate actions (in this case, registering them dynamically at an appropriate time). |
@dmfs @ekalin We fought with this problem in the widget app here: plusonelabs/calendar-widget#298 So although sending anonymous broadcast is better than nothing, could we, in addition to it, have a notification specifically targeted at our ToDo Agenda app, please. On Tasks support with a link to the Beta version please see plusonelabs/calendar-widget#308 |
I see. Adding an explicit broadcast for every app wouldn't scale very well. I see two options:
The first option is definitely the quicker one, so I'll give it a try. |
@dmfs It came to me that you could create an option "App packages to notify on task updates" and allow a User (who will have an instruction in FAQ...) to type needed package(s) manually. |
Let's try the first option above first, at least as a temporary solution. It should be fairly easy to implement. I'd like to avoid asking users questions about package names. |
Since Android 8 it's not possible to listen to implicit broadcasts anymore when the reciever is declared in the AndroidManifest.xml. In a previous commit we disabled sending out broadcasts to other apps. This caused some trouble. This commit tries to resolve all broadcast receivers which listen for PROVIDER_CHANGED and send individual broadcasts to each of them.
Can you check whether the commit in branch stories/822-restore-broadcast-kind-of fixes this? |
@dmfs I registered another Intent.ACTION_PROVIDER_CHANGED for "org.dmfs.tasks" in ToDo Agenda app and checked. But this your commit doesn't work: as I found out by adding debugging messages to your code, this doesn't find any receivers except your own:
gives: 2019-08-08 20:42:58.819 12364-12364/org.dmfs.tasks I/Utils: ContentUri: content://org.dmfs.tasks, resolved packages: [ResolveInfo{291408c org.dmfs.tasks/.homescreen.TaskListWidgetProvider m=0x308000}, ResolveInfo{1cb53d5 org.dmfs.tasks/.homescreen.TaskListWidgetProviderLarge m=0x308000}, ResolveInfo{2dbc7ea org.dmfs.tasks/.notification.TaskNotificationHandler m=0x308000}] But this causes an update in ToDo Agenda widget:
|
I've tested without any From what I understand of the changes introduced in O, only receivers are affected (in how they must register the receivers), but senders can continue doing what they did before. |
Without |
I'm not 100% sure, but this might be because OpenTasks does not registers the receivers dynamically. Since this registration can be tricky (at least for widgets), one solution might be
It's not elegant, but at least there's no need to hard code applications that might be interested in the broadcast. |
right, that could work too. I'll ponder on this. |
I implemented "Register for notifications on Open Tasks provider changes" in the "Todo Agenda" app. |
@yvolk just to be clear, you still need an explicit broadcast, right? In this case I'll hard code your package name for now. |
Yes, please |
Since Android 8 it's not possible to listen to implicit broadcasts anymore when the reciever is declared in the AndroidManifest.xml. In a previous commit we disabled sending out broadcasts to other apps. This caused some trouble. For new we hard code 3rd party receiver package names in a resource array. This is supposed to be changed later on, see #824.
Ok, I've updated the branch. Please let me know if that works for you. |
Yes, it works, thank you. |
Todo Agenda is a widget that displays calendar events and tasks, and it can display tasks from OpenTasks. (I wrote the support for tasks, but I'm not the maintainer.)
It would be nice if the widget were updated whenever a task is added/changed/completed/etc. From what I've gathered, a PROVIDER_CHANGED broadcast is sent in these cases, but on Oreo and later it's limited to OpenTasks' package only:
opentasks/opentasks-provider/src/main/java/org/dmfs/provider/tasks/TaskProvider.java
Line 1322 in e711e6e
I'm not sure why that limitation (and the comment about figuring out how to do it in 8+). I've tested with a simple app that sends an equal broadcast (without specifying the package) and the widget was able to receive the broadcast.
Could that
setPackage
be removed, so that any app interested in knowing about changes in tasks can be notified?The text was updated successfully, but these errors were encountered: