简体   繁体   English

如何使用 Android Studio 中的意图读取一周的日历事件?

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

Hey I'm making a voice assistant application, and want to let the user know about upcoming events so I want to read events using intents.嘿,我正在制作一个语音助手应用程序,并且想让用户知道即将发生的事件,所以我想使用意图读取事件。 I have been trying to read google calendar API and figure out but I couldn't quite get it.我一直在尝试阅读谷歌日历 API 并弄清楚但我不太明白。 I will greatly appreciate anyone who can help me out...我将非常感谢任何可以帮助我的人...

I have implemented a way to create a new event using:我已经实现了一种使用以下方法创建新事件的方法:

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

Try to do in this way尝试这样做

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