// 获取要出入的gmail账户的id String calId = ""; Cursor userCursor = getContentResolver().query( Uri.parse(calanderURL), null, null, null, null); if (userCursor.getCount() > 0) { userCursor.moveToFirst(); calId = userCursor.getString(userCursor.getColumnIndex("_id")); } Calendar beginTime = Calendar.getInstance(); beginTime.set(2013, 10, 26, 16, 20); long startMillis = beginTime.getTimeInMillis(); Calendar endTime = Calendar.getInstance(); endTime.set(2013, 10, 26, 17, 20); long endMillis = endTime.getTimeInMillis(); ContentValues event = new ContentValues(); event.put("title", "测试完成2"); //标题 event.put("description", "真的好开心可以添加提醒了.lol~"); //描述 // 插入[email protected]这个账户 event.put("calendar_id", calId); //账户id event.put("dtstart", startMillis); //开始时间 event.put("dtend", endMillis); //结束时间 event.put("hasAlarm", 1); //是否提醒 event.put(Events.EVENT_TIMEZONE, "China/Beijing"); //时区 Uri newEvent = getContentResolver().insert(Uri.parse(calanderEventURL), event); long id = Long.parseLong(newEvent.getLastPathSegment()); Toast.makeText(this, id + event.get("title").toString(),Toast.LENGTH_SHORT).show(); ContentValues values = new ContentValues(); values.put(Reminders.MINUTES, 10); values.put(Reminders.EVENT_ID, id); values.put(Reminders.METHOD, Reminders.METHOD_ALERT); getContentResolver().insert(Reminders.CONTENT_URI, values); Toast.makeText(this, "插入事件成功!!!",Toast.LENGTH_SHORT).show();