public int addEvent(Context context,String color,int calendarID,String name,String location,String description,Date dateBegin,Date dateEnd) { long startMillisEpoch; long endMillisEpoch; Calendar beginTime = Calendar.getInstance(); beginTime.setTime(dateBegin); startMillisEpoch = beginTime.getTimeInMillis(); Calendar endTime = Calendar.getInstance(); endTime.setTime(dateEnd); endMillisEpoch = endTime.getTimeInMillis(); int eventcolor; try { eventcolor = color.parsecolor(color); } catch (Exception e) { // Get a random color Random random = new Random(); eventcolor = MyApp.RANDOM_colorS[random.nextInt(MyApp.RANDOM_colorS.length)]; } ContentValues values = new ContentValues(); values.put(CalendarContract.Events.CALENDAR_ID,calendarID); values.put(CalendarContract.Events.DTSTART,startMillisEpoch); values.put(CalendarContract.Events.DTEND,endMillisEpoch); values.put(CalendarContract.Events.Title,name); values.put(CalendarContract.Events.EVENT_LOCATION,location); values.put(CalendarContract.Events.DESCRIPTION,description); values.put(CalendarContract.Events.EVENT_color,eventcolor); // NOTE: Every event MUST have a timezone. Otherwise,// the application will throw an IllegalArgumentException values.put(CalendarContract.Events.EVENT_TIMEZONE,TimeZone.getDefault().getdisplayname()); // Put default values values.put(CalendarContract.Events.ALL_DAY,NON_ALL_DAY); values.put(CalendarContract.Events.GUESTS_CAN_INVITE_OTHERS,1); Uri calUri = context.getContentResolver().insert(CalendarContract.Events.CONTENT_URI,values); if (calUri != null) { try { return Integer.parseInt(calUri.getLastPathSegment()); } catch (Exception e) { return -1; } } return -1; }
解决这类问题的任何想法?亲切的问候.
解决方法 根据 API我猜你错过了.execute()Uri calUri = context.getContentResolver() .insert(CalendarContract.Events.CONTENT_URI,values) .execute();
也是check this question
总结以上是内存溢出为你收集整理的android – 无法在Google日历中插入多个事件全部内容,希望文章能够帮你解决android – 无法在Google日历中插入多个事件所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)