William Hunter Active Member Licensed User Longtime User Sep 2, 2013 #1 I have written a widget that displays the battery level on both discharge and charge. I have set the update interval to 30 minutes. The widget runs as it should with this interval setting. I think that automatic update is used to prevent the OS from dropping the app, but I don’t know this for sure. Could someone explain the reason for the need of an automatic update? I know my widget will run with auto update turned off, but is there a valid reason not to go this way? Also, why would there be a need for a range of varying intervals, and how does one decide on just what a particular interval should be? Any help would be greatly appreciated.
I have written a widget that displays the battery level on both discharge and charge. I have set the update interval to 30 minutes. The widget runs as it should with this interval setting. I think that automatic update is used to prevent the OS from dropping the app, but I don’t know this for sure. Could someone explain the reason for the need of an automatic update? I know my widget will run with auto update turned off, but is there a valid reason not to go this way? Also, why would there be a need for a range of varying intervals, and how does one decide on just what a particular interval should be? Any help would be greatly appreciated.
NeoTechni Well-Known Member Licensed User Longtime User Sep 3, 2013 #2 The way I did it in my app, which lets users have multiple widget types, is that the user can pick a different update delay for each widget. Animated widgets can set their own delay, bypassing the setting. But yes, a small delay (15 minutes or so?) is what I heard keeps the app in memory Upvote 0
The way I did it in my app, which lets users have multiple widget types, is that the user can pick a different update delay for each widget. Animated widgets can set their own delay, bypassing the setting. But yes, a small delay (15 minutes or so?) is what I heard keeps the app in memory
Erel B4X founder Staff member Licensed User Longtime User Sep 3, 2013 #3 The automatic update should only be used if you want to create a widget that is updated every x minutes. For example a weather widget that checks for updates every hour. Upvote 0
The automatic update should only be used if you want to create a widget that is updated every x minutes. For example a weather widget that checks for updates every hour.
William Hunter Active Member Licensed User Longtime User Sep 3, 2013 #4 Erel said: The automatic update should only be used if you want to create a widget that is updated every x minutes. For example a weather widget that checks for updates every hour. Click to expand... @NeoTechni & Erel – Thank you both for your responses. I need a little further clarification. NeoTechni’s statement, “But yes, a small delay (15 minutes or so?) is what I heard keeps the app in memory”, confirms what I have read elsewhere. Whereas, Erel’s comments seem to indicate that automatic update is only used to update data input from an outside source (Internet), and has no effect on keeping the app in memory. With this in mind, it would seem that my widget should have automatic update set to 0. Erel would you please elaborate on this? I’ve read a number of conflicting comments on this subject, and things are still unclear to me. Best regards Upvote 0
Erel said: The automatic update should only be used if you want to create a widget that is updated every x minutes. For example a weather widget that checks for updates every hour. Click to expand... @NeoTechni & Erel – Thank you both for your responses. I need a little further clarification. NeoTechni’s statement, “But yes, a small delay (15 minutes or so?) is what I heard keeps the app in memory”, confirms what I have read elsewhere. Whereas, Erel’s comments seem to indicate that automatic update is only used to update data input from an outside source (Internet), and has no effect on keeping the app in memory. With this in mind, it would seem that my widget should have automatic update set to 0. Erel would you please elaborate on this? I’ve read a number of conflicting comments on this subject, and things are still unclear to me. Best regards
Erel B4X founder Staff member Licensed User Longtime User Sep 4, 2013 #5 You should not force your app to stay running. Your app should only run when it needs to. How are you intercepting the battery level? With PhoneEvents (dynamic receiver)? If yes then then the interval will determine when the widget will be updated. This is not always the case. See this tutorial: Intent Filters - Intercepting SMS messages in the background If I remember correctly you cannot create a static receiver for the battery intent which means that you should rely on the automatic updates mechanism. Upvote 0
You should not force your app to stay running. Your app should only run when it needs to. How are you intercepting the battery level? With PhoneEvents (dynamic receiver)? If yes then then the interval will determine when the widget will be updated. This is not always the case. See this tutorial: Intent Filters - Intercepting SMS messages in the background If I remember correctly you cannot create a static receiver for the battery intent which means that you should rely on the automatic updates mechanism.
tunderin Member Licensed User Longtime User Sep 4, 2013 #6 My widget service receives email at user defined intervals, by default 15 mins (using StartServiceAt). Is there any merit in using stopservice after each mail fetch? Will the widget service still be able to service widget events if I do? Upvote 0
My widget service receives email at user defined intervals, by default 15 mins (using StartServiceAt). Is there any merit in using stopservice after each mail fetch? Will the widget service still be able to service widget events if I do?
Erel B4X founder Staff member Licensed User Longtime User Sep 5, 2013 #7 Note that it is better to start a new thread for a new question. The widget service will be recreated if it needs to. So it will work fine if you call StopService (whether it is better or not in this case? I'm not sure whether you will see any difference). Upvote 0
Note that it is better to start a new thread for a new question. The widget service will be recreated if it needs to. So it will work fine if you call StopService (whether it is better or not in this case? I'm not sure whether you will see any difference).
William Hunter Active Member Licensed User Longtime User Sep 9, 2013 #8 For those interested: 1. Yes, I am intercepting the battery level with PhoneEvents. 2. The only way I could get my widget to continue monitoring battery level without interruption was to leave the update interval set to 0, and use the line of code below, to start the service every 15 minutes. Code: Copy Sub Service_Start (StartingIntent AsIntent) StartServiceAt("",DateTime.Now + 900 * 1000,True) 'every 15 mins End Sub Thanks to all who replied to my query. Upvote 0
For those interested: 1. Yes, I am intercepting the battery level with PhoneEvents. 2. The only way I could get my widget to continue monitoring battery level without interruption was to leave the update interval set to 0, and use the line of code below, to start the service every 15 minutes. Code: Copy Sub Service_Start (StartingIntent AsIntent) StartServiceAt("",DateTime.Now + 900 * 1000,True) 'every 15 mins End Sub Thanks to all who replied to my query.