安卓(Android) 怎么使用日历(Calendar)模型与 Attendee 属性创建iCalendar与 Attendee

2019年10月1日22:54:09安卓(Android) 怎么使用日历(Calendar)模型与 Attendee 属性创建iCalendar与 Attendee已关闭评论 298 1066字阅读3分33秒

1.简介

安卓(Android) 怎么使用日历(Calendar)模型与 Attendee 属性创建iCalendar与 Attendee ?——请看下文。

2.示例代码

/**
 * 版权所有 编程十万个怎么办(www.tah1986.com)
 */

import android.content.ContentResolver;
import android.content.Context;
import android.net.Uri;
import android.provider.CalendarContract;
import com.android.calendar.CalendarEventModel;
import java.io.
     
    public static void addAttendeeToEvent(
            CalendarEventModel.Attendee attendee, VEvent event) {
        if (attendee == null || event == null)
            return;
        Attendee vAttendee = new Attendee();
        vAttendee.addProperty(Attendee.CN, attendee.mName);

        String participationStatus;
        switch (attendee.mStatus) {
        case CalendarContract.Attendees.ATTENDEE_STATUS_ACCEPTED:
            participationStatus = "ACCEPTED";
            break;
        case CalendarContract.Attendees.ATTENDEE_STATUS_DECLINED:
            participationStatus = "DECLINED";
            break;
        case CalendarContract.Attendees.ATTENDEE_STATUS_TENTATIVE:
            participationStatus = "TENTATIVE";
            break;
        case CalendarContract.Attendees.ATTENDEE_STATUS_NONE:
        default:
            participationStatus = "NEEDS-ACTION";
            break;
        }
        vAttendee.addProperty(Attendee.PARTSTAT, participationStatus);
        vAttendee.mEmail = attendee.mEmail;

        event.addAttendee(vAttendee);
    }
}

 
继续阅读