你必須下載雙週首先的.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);
}
是否可以不使用第三帕蒂jar文件做了什麼? –
不需要雙週刊Jar對於它,我可以幫助你,因爲我在應用程序中實現了同樣的功能 –