2013-11-16 3 views
11

모든 변경 사항을 적용하려면 Content Provider을 사용해야한다는 것을 이해했습니다. 그러나 API14을 시작한다는 사실을 깨닫게되었습니다. ""대신 " 건물 "내 자신의 하나.
예를 어디에서 볼 수 있습니까?
누군가이 청취자의 핵심을 게시 할 수 있습니까?Android 캘린더 변경 사항을 들어보십시오.

감사

답변

22

먼저 당신은 매니페스트에 수신기의이 유형을 추가해야합니다

public class CatchChangesReceiver extends BroadcastReceiver { 

    @Override 
    public void onReceive(Context context, Intent intent) { 
    // add processing here with some query to content provider 
     // in my project I use this selection for getting events: 
     final String SELECTION = CalendarContract.Events.CALENDAR_ID + "=" 
      + calendarId + " AND " + "(" 
      + CalendarContract.Events.DIRTY + "=" + 1 + " OR " 
      + CalendarContract.Events.DELETED + "=" + 1 + ")" + " AND " 
      + CalendarContract.Events.DTEND + " > " 
      + Calendar.getInstance().getTimeInMillis(); 
    } 
} 
+0

감사합니다 :

<receiver android:name="your.package.name.CatchChangesReceiver" android:priority="1000" > <intent-filter> <action android:name="android.intent.action.PROVIDER_CHANGED" /> <data android:scheme="content" /> <data android:host="com.android.calendar" /> </intent-filter> </receiver> 

그리고 방송 수신기를 확장하는 간단한 클래스를 만들! 위대한 작품! – SagiLow

+0

그렇지 않으면 설명서에서 얻을 수 없으므로 통찰력을 가져 주셔서 감사합니다. –

+0

전체 예제를 얻을 수 있습니까? – Nikita

관련 문제