如何从日历事件,Android删除参加者?

如何从日历事件,Android删除参加者?,第1张

概述我想更新日历活动. 我知道如何更新标题,位置,使用ContentResolver添加新的与会者 但我不知道如何删除一些与会者,例如通过电子邮件. 这是我到目前为止,我解析JSONObject并获取所有新信息: public void updateEvent(Context context, long eventId, JSONObject updateObj) { ContentR 我想更新日历活动.

我知道如何更新标题,位置,使用ContentResolver添加新的与会者

但我不知道如何删除一些与会者,例如通过电子邮件.

这是我到目前为止,我解析JSONObject并获取所有新信息:

public voID updateEvent(Context context,long eventID,JsONObject updateObj) {        ContentResolver cr = context.getContentResolver();        ContentValues values = new ContentValues();        Uri updateUri = null;        long startDate = updateObj.optLong("startDate");        long endDate = updateObj.optLong("endDate");        String Title = updateObj.optString("Title");        String description = updateObj.optString("description");        String location = updateObj.optString("location");        int eventStatus = updateObj.optInt("eventStatus");        JsONArray addAtt = updateObj.optJsONArray("add_attendee");        JsONArray deleteAtt = updateObj.optJsONArray("delete_attendee");        values.put(Events.EVENT_LOCATION,location);        values.put(Events.DESCRIPTION,Title);        values.put(Events.Title,Title);        values.put(Events.DTSTART,startDate);        values.put(Events.DTEND,endDate);        values.put(Events.STATUS,eventStatus);        updateUri = ContentUris.withAppendedID(Events.CONTENT_URI,eventID);        int rows = cr.update(updateUri,values,null,null);        Log.i(TAG,"Rows updated: " + rows);          // add new attendees        for(int i=0; i<addAtt.length(); i++){                       JsONObject attObj = addAtt.optJsONObject(i);            String name = attObj.optString("name");            String email = attObj.optString("email");                       int relationship = attObj.optInt("relationship");            int type = attObj.optInt("type");            int status = attObj.optInt("status");            values = new ContentValues();            values.put(Attendees.ATTENDEE_name,name);            values.put(Attendees.ATTENDEE_EMAIL,email);            values.put(Attendees.ATTENDEE_RELATIONSHIP,relationship); // had 0            values.put(Attendees.ATTENDEE_TYPE,type);// had 0            values.put(Attendees.ATTENDEE_STATUS,status); // had 3 - invited            values.put(Attendees.EVENT_ID,eventID);            updateUri = ContentUris.withAppendedID(Attendees.CONTENT_URI,eventID);            cr.update(updateUri,null);        }        // remove attendees        for(int i=0; i<removeAtt.length(); i++){                        JsONObject attObj = addAtt.optJsONObject(i);                    // HERE  iS A PROBLEM//          Uri deleteUri = ContentUris.withAppendedID(Attendees.CONTENT_URI,eventID);//          int rows = cr.delete(deleteUri,null);        }    }

[编辑]

我也尝试过:

String selection = Attendees.ATTENDEE_EMAIL + " = ?";String[] selectionArgs = new String[] {"[email protected]"};Uri deleteUri = ContentUris.withAppendedID(Events.CONTENT_URI,eventID);rows = cr.delete(deleteUri,selection,selectionArgs);

得到错误:

java.lang.IllegalArgumentException: Selection not permitted for content://com.androID.calendar/events/524

请帮忙,

解决方法 要通过电子邮件和事件ID删除特定与会者:

String selection = "(" + Attendees.EVENT_ID + " = ?) AND (" + Attendees.ATTENDEE_EMAIL + " = ?)";    String[] selectionArgs = new String[] {eventID+"","[email protected]"};    rows = cr.delete(Attendees.CONTENT_URI,selectionArgs);    Log.i(TAG,"Rows updated: " + rows);
总结

以上是内存溢出为你收集整理的如何从日历事件,Android删除参加者?全部内容,希望文章能够帮你解决如何从日历事件,Android删除参加者?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1125304.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-30
下一篇 2022-05-30

发表评论

登录后才能评论

评论列表(0条)

保存