I am working on a rooted device. I am trying make a simple widget and a launcher with a widget host. I am following this developer link as it is.
My widget has a single button which prints a random number when clicked.
Even if a widget is not added to screen, when the system boots, it sends a broadcast to each widget in the system. Every widget gets ACTION_APPWIDGET_ENABLED action and this followed by ACTION_APPWIDGET_UPDATE
Depending on the system I am using, it takes anywhere from 2sec(on the emulator) to 30seconds. The widget can be added to the screen even before receiving these broadcast. I get this peculiar scenario where the widget is added to the screen but is unresponsive till the broadcasts are received.
If I manually try to send the broadcast, it makes no difference as the broadcasts are queued and are sent in order by the system.
I am trying it on Android12.
The class which is responsible for sending this broadcasts is AppWidgetServiceImpl
What I would like to know is how can I get my widget to respond faster? (Android QuickSearch is able to start its SearchActivity even before first broadcast is received. How?) Is there a way to trigger the AppWidgetProvider update method on as soon as the screen is visible?
from Android widgets: Delay in getting the first ENABLED and UPDATE broadcast for widgets
No comments:
Post a Comment