2012-07-12 3 views
5

캘린더 위젯을 개발 중이며 날짜를 변경하면 DATE_CHANGED 메시지를받을 수 없습니다. MANUALLY.Android 위젯이 DATE_CHANGED 메시지를받을 수 없습니다.

무엇이 문제입니까?

매니페스트에 내 코드는 다음과 같습니다

<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> 

그리고 나는 이런 식으로받을려고 :

@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); 
} 

하지만 수동으로 시스템 날짜를 변경하면 로그가 인쇄되지 않습니다.

감사합니다.

는 UPDATE : 나는 Intent.ACTION_TIME_CHANGED 이것을 해결

는 정말 DATE_CHANGED의 버그입니다.

답변

7

사용이 의도 :

<intent-filter> 
     <action android:name="android.intent.action.TIME_SET"/> 
</intent-filter> 

그리고납니다

@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); 
} 
+0

그러나 이것은 시간이 변경됩니다 때마다 다시하고 다시 브로드 캐스트 리시버를 호출합니다 귀하의 배터리를 소모하게됩니다. – Akram

+1

@Akki 시스템 시간 또는 날짜를 수동으로 변경하지 않으면이 TIME_SET 의도를 보내지 않을 것이라고 테스트했습니다. 배터리가 여기에 안전합니다. :) – herbertD

+0

그래서 사용자가 수동으로 날짜를 변경할 때이 수신기를 호출하고 싶습니까? – Akram

관련 문제