簡體   English   中英

如何使用 Android Studio 中的意圖讀取一周的日歷事件?

[英]How to read calendar event for the week using intents in Android Studio?

嘿,我正在制作一個語音助手應用程序,並且想讓用戶知道即將發生的事件,所以我想使用意圖讀取事件。 我一直在嘗試閱讀谷歌日歷 API 並弄清楚但我不太明白。 我將非常感謝任何可以幫助我的人...

我已經實現了一種使用以下方法創建新事件的方法:

Intent intent = new Intent(Intent.ACTION_INSERT);
intent.setData(CalendarContract.Events.CONTENT_URI);
intent.putExtra(CalendarContract.Events.TITLE, titleString);
intent.putExtra(CalendarContract.Events.DESCRIPTION, description);
intent.putExtra(CalendarContract.Events.EVENT_LOCATION, "Worldwide");
intent.putExtra(CalendarContract.Events.ALL_DAY, true);
intent.putExtra(Intent.EXTRA_EMAIL, "test@gmail.com");
intent.putExtra(CalendarContract.Events.EVENT_TIMEZONE, timeZone.getID());
intent.putExtra(CalendarContract.Events.HAS_ALARM, 1);

嘗試這樣做

Cursor cursor = context.getContentResolver().query(
                        Uri.parse("content://com.android.calendar/events"),
                        new String[] { "calendar_id", "title", "description","dtstart", 
                        "dtend", "eventLocation" }, null, null, null);
cursor.moveToFirst();

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM