Android アプリケーションのカレンダーでイベントの検索と選択を実装しようとしています。find と select の実装はまったく異なると思います。
私は無駄にウェブを精査しました。助けていただければ幸いです。
Android アプリケーションのカレンダーでイベントの検索と選択を実装しようとしています。find と select の実装はまったく異なると思います。
私は無駄にウェブを精査しました。助けていただければ幸いです。
manifest
<uses-permission android:name="android.permission.READ_CALENDAR" />
これらの例は <= 2.1 バージョンのものです。
最初; 存在するカレンダーを見つける
Cursor cursor = cr.query(Uri.parse("content://calendar/calendars"), new String[]{ "_id", "displayname" }, null, null, null);
cursor.moveToFirst();
String[] CalNames = new String[cursor.getCount()];
int[] CalIds = new int[cursor.getCount()];
for (int i = 0; i < CalNames.length; i++) {
CalIds[i] = cursor.getInt(0);
CalNames[i] = cursor.getString(1);
cursor.moveToNext();
}
cursor.close();
すべてのイベントを取得し、範囲を指定して特定のイベントを取得します
ContentResolver contentResolver = getContentResolver()
。
Uri.Builder builder = Uri.parse(getCalendarUriBase() + "/instances/when").buildUpon();
long now = new Date().getTime();
ContentUris.appendId(builder, now - DateUtils.MILLIS_PER_DAY*10000);
ContentUris.appendId(builder, now + DateUtils.MILLIS_PER_DAY * 10000);
次に、ID = 1 のカレンダーからイベント ID をログに記録したいとします。
Cursor eventCursor = contentResolver.query(builder.build(),
new String[] { "event_id"}, "Calendars._id=" + 1,
null, "startDay ASC, startMinute ASC");
// For a full list of available columns see http://tinyurl.com/yfbg76w
while (eventCursor.moveToNext()) {
String uid2 = eventCursor.getString(0);
Log.v("eventID : ", uid2);
}
一部のソース コードについては、 Jim Blackler のAccessing the internal calendar database inside Google Android applicationsおよびAndroid Calendar Eventsを確認してください。