繁体   English   中英

Android获取日历事件的.ics文件

[英]Android get .ics file for calendar events

我可以使用日历事件游标从Android设备获取日历事件。 但我想将其提取为.ics文件。

是否可以提取为.ics? 如果不能,我们可以从光标生成一个.ics文件吗?

我期望一个.ics文件如下所示:

BEGIN:VCALENDAR
VERSION:1.0
BEGIN:VEVENT
CATEGORIES:MEETING
STATUS:TENTATIVE
DTSTART:19960401T033000Z
DTEND:19960401T043000Z
SUMMARY:Your Proposal Review
DESCRIPTION:Steve and John to review newest proposal material
CLASS:PRIVATE
END:VEVENT
END:VCALENDAR

编辑:另外,我想将多个日历事件分组到单个.ics文件中

您必须首先下载BiWeekly.jar http://sourceforge.net/projects/biweekly

                  ical = new ICalendar();// Creating ical object

                            VEvent event = new VEvent();

                            Summary summary = event.setSummary("Meeting");
                            Attendee attendee1=event.addAttendee(email);
                            Attendee attendee2=event.addAttendee(myEmail);
                            Location location=event.setLocation(venue);

                            summary.setLanguage("en-us");
                            start = dt;
                            event.setDescription(comments);
                            event.setDateStart(new DateStart(start, false));


                            try {
                                if(chosenFile!=null)
                                event.addAttachment(new Attachment("", chosenFile));// adding attachment
                            } catch (IOException e) {
                                // TODO Auto-generated catch block
                                e.printStackTrace();
                            }
                            ical.addEvent(event);

                            String filePath =       
      Environment.getExternalStorageDirectory() + "/meetings.ics";
                            file = new File(filePath);
      File root = new File(Environment.getExternalStorageDirectory(), "Notes");
                if (!root.exists()) {
                    root.mkdirs();
                }
                File file = new File(root,"meetings.ics");
                Biweekly.write(ical).go(file);
                            if(!isConnected())
                                showdialog();
                            else
                            {

                                    // Taking the user to device calender to enable user to store the meeting in local calendar as well if he wishes to


                                    Intent calIntent = new Intent(Intent.ACTION_INSERT); 
                                    calIntent.setType("vnd.android.cursor.item/event");    
                                    calIntent.putExtra(Events.TITLE, "Meeting"); 
                                    calIntent.putExtra(Events.EVENT_LOCATION, venue); 
                                    calIntent.putExtra(Events.DESCRIPTION, comments);
                                    calIntent.putExtra(CalendarContract.Attendees.ATTENDEE_NAME, name); 
                                    calIntent.putExtra(CalendarContract.Attendees.ATTENDEE_EMAIL, email);
                                    calIntent.putExtra(CalendarContract.EXTRA_EVENT_BEGIN_TIME, 
                                         start.getTime()); 
                                    calIntent.putExtra(CalendarContract.EXTRA_EVENT_END_TIME, 
                                             start.getTime()+3600000);

                                    startActivityForResult(calIntent, 1);

                            }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM