This time, however, we decided to tell you why you shouldn't. One of them is when widgets freeze, and the other is when widgets don't show up in the widgets list. Let's see what the root cause of these issues is, and what we can do about it.
When widgets freeze As you know, we have an app. It's called My Day and it helps you keep track of the most important days in your life. To make user experience better, we developed a widget that's basically, a countdown timer which displays days, minutes, seconds, or any other time unit that a user chooses. The cost for IT services in the world The content of our widget is often renewed which makes the widget prone to freezing.
The same problem can be detected in widgets that display clock, graphs, weather, and other content that gets updated frequently. Widgets occasionally freeze entirely Reported Apr 2, The graphics are stuck in one state and will not change. So if you use the stock Power Control Toggle widget the one with wifi, bluetooth, brightness control, etc.
After reading all comments, I came to the following conclusions: The bug is detected on Android OS 4. The reproduction of the bug is unstable in all widgets. Even a standard Power Widget is not immune to this issue. While updating widgets, AppWidgetService can sometimes receive RemoteException error which results in a reference to a CallBack being removed.
If you get "host. The only way out is to restart the launcher, because a CallBack gets assigned after AppWidgetHost calls a method startListening , which can only happen in the method onCreate on in the Launcher class.
This story is described in the comment Here is an example of code the author of the comment used to illustrate the widget freezing problem. This code was taken from Android OS: He created a system image and simply fixed the issue in the source code. The bug disappeared as if it has never been there. The only thing is that it disappeared on his personal device only. The rest of the world that uses Android has to bear with the widget freezing problem, unless they know how to properly reflash the system.
Otherwise, you can restart a launcher and it will temporarily fix the problem. What conclusions can we come to? The root of all evil is incorrect functioning of the launcher.
There is no fully-fledged solution to the problem. But we didn't give up and investigated the issue further. Alternative solution It turns out that the widget freezing bug is not only detected when a launcher fails, but also when time on a device is changed by a user. It's enough to go a day back in time, and a widget won't update. My suspicion fell on the service that sends updates to the widget. TimerTask, which this service has under the hood, is the cause of the problem.
I found an interesting question on StackoverFlow, which illustrates a similar problem -- TimerTask stops working after the time is changed. This only confirmed my assumption.
When we substituted TimerTask with Handler Our widget ceased freezing! Nevertheless, system bugs still remain unfixed. To that I can only add that widgets are rather unpredictable per se. After I tested widgets on different devices, I discovered that the problem with the widget lists, is, in fact, more serious than it seems. Even if you do launch Activity, a widget won't always go where it belongs. There are two ways to solve this problem.
The author suggests to reboot the device to solve this issue. Solution 2 I googled a little more, and found that Android 4. The cause of the problem Since restarting a launcher helped us solve the problem, it means that the launcher is again the cause of the problem. More than that, I found out that if you delete an app, its widget lingers in the list until you reboot the device.
I tested this issue on my Nexus 5 Android 5. Unfortunately, I didn't find the way to fix the bug, but here is a piece of advice for you: I hope Google pays attention to the bugs in their Android system to make everybody happy and the world a better place.