I am developing a calendar widget, and I can't receive the DATE_CHANGED message when I changed the date MANUALLY.
What is the problem?
My code in Manifest is :
<receiver android:name="com.widget.calendar.CalendarWidgetProvider">
<intent-filter>
<action android:name="android.appwidget.action.APPWIDGET_UPDATE" />
<action android:name="android.intent.action.DATE_CHANGED"/>
</intent-filter>
<!-- This specifies the widget provider info -->
<meta-data android:name="android.appwidget.provider"
android:resource="@xml/widgetinfo" />
</receiver>
And I tried to receive it like this:
@Override
public void onReceive(Context ctx, Intent intent) {
final String action = intent.getAction();
if (action.equalsIgnoreCase("android.intent.action.DATE_CHANGED")) {
Log.e(TAG, "Date changed.....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
super.onReceive(ctx, intent);
}
But the log is not print when I change the system date manually.
Thanks!
UPDATE:
I solved this with Intent.ACTION_TIME_CHANGED, It's really a bug of DATE_CHANGED.
Use this intent:
<intent-filter>
<action android:name="android.intent.action.TIME_SET"/>
</intent-filter>
And receive:
@Override
public void onReceive(Context ctx, Intent intent) {
final String action = intent.getAction();
if (action.equalsIgnoreCase("android.intent.action.TIME_SET")) {
Log.e(TAG, "Date changed.....!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
super.onReceive(ctx, intent);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With