Android Question Update widget when phone configuration change

ducphu

Active Member
Licensed User
Longtime User
Hi all,

I have a widget which data is drew using canvas. I already know that in some cases, when phone configuration is changed, the widget data is lost and I need to update it (for example, when phone is rotated)

In my app, I used broadcastreceiver to catch screen rotation event using "android.intent.action.CONFIGURATION_CHANGED"

I want to ask, is there any other phone changes in which I need to update my widget also? maybe changing of theme or any phone settings...?? If there is, can anyone tell me which intent is corresponded to that event also?
 

ducphu

Active Member
Licensed User
Longtime User
Yes, I declare my service as sticky service. I ask abt this because I randomly encounter that my widget loses its data but still not manage to find out which causes it..
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
Ok. But the issue with my widget is that I set it to be updated once a day. If the widget data is lost, it means that it can only get back the data next day. Anyway, the most headache here is I don't know what can cause this to happen.
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
Hi Erel but sorry I don't get what you mean. My widget basically displays a calendar. The data is sent to widget using canvas draw, at time of creation and is updated daily. In my rv_RequestUpdate sub, after finish updating, I put a StopService("") command. So basically, during the day, my service is not running at all. I only startup the service to update my widget in 2 cases, either by schedule (daily) or when "android.intent.action.CONFIGURATION_CHANGED" is raised ( I have another sticky service to monitor this)

When my widget loses its data, it becomes a blank widget, i.e the background is still there but all the numbers, texts.. drew using canvas are gone. This happens like before I used broadcastreceiver to capture when the phone is rotated. That's why I think of, maybe some other intents are being raised
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
I think even if I leave the service running, it doesn't help if this issue is caused by an intent as it doesn't call rv_RequestUpdate.
Yes, I may change the update interval to 30mins but it is not really a good solution as in the worst case, it may take 30mins until my widget is recovered, and, during that 30mins, my widget is dead...which is unacceptable to the customer. Really hope that we can have a better solution for this.

Btw, what do you think is the cause of this issue? I dont see how "Android can kill the process from time to time" cause this issue, as my widget doesn't have any real time, continuous data tranfer with any process...
 
Upvote 0

ducphu

Active Member
Licensed User
Longtime User
humm but can you tell me what is the mechanism behind this? In which case or which event that the launcher will restart widget process? Sorry for my noob :(
 
Upvote 0
Top