android:updatePeriodMillis 속성으로 주기적으로 업데이트하는 방법이 있지만 최소 주기가 30분인걸로 압니다.. 안돌수도 있는거 같고요.
날짜가 변경될때 update가 필요한데 이경우엔 최대 30분의 딜레이가 생기겠죠..
BroadcastReceiver에 Intent.ACTION_TIME_TICK 로 해봤지만 제대로 돌지 않는거 같네요.
혹시 해보신분 있나요?
updatePeriodMillis
attribute defines how often the App Widget framework should request an update from the AppWidgetProvider
by calling the onUpdate()
method. The actual update is not guaranteed to occur exactly on time with this value and we suggest updating as infrequently as possible—perhaps no more than once an hour to conserve the battery. You might also allow the user to adjust the frequency in a configuration—some people might want a stock ticker to update every 15 minutes, or maybe only four times a day.Note: If the device is asleep when it is time for an update (as defined by updatePeriodMillis
), then the device will wake up in order to perform the update. If you don't update more than once per hour, this probably won't cause significant problems for the battery life. If, however, you need to update more frequently and/or you do not need to update while the device is asleep, then you can instead perform updates based on an alarm that will not wake the device. To do so, set an alarm with an Intent that your AppWidgetProvider receives, using the AlarmManager
. Set the alarm type to either ELAPSED_REALTIME
or RTC
, which will only deliver the alarm when the device is awake. Then set updatePeriodMillis
to zero ("0"
).
<action android:name="android.intent.ACTION_TIME" />
이런식으로 해보세요
안드로이드 developer사이트의 내용 입니다.
How often, in milliseconds, that this AppWidget wants to be updated. The AppWidget manager may place a limit on how often a AppWidget is updated.
This field corresponds to the android:updatePeriodMillis
attribute in the AppWidget meta-data file.
Note: Updates requested with updatePeriodMillis
will not be delivered more than once every 30 minutes.