Java Android Studio不会插入日历事件

Java Android Studio不会插入日历事件,java,android,android-calendar,android-event,Java,Android,Android Calendar,Android Event,我正在写一个事件搜索。我们现在添加了一些Web服务,事件不会自动推送到日历中。自动添加功能不再工作了代码在这里请问尽可能多的问题我在android清单中有权限。我所看到的一切都应该是好的,我把它叫做这里,代码是什么。运行没有错误只是从未在日历中显示 SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext()); AutoAdd

我正在写一个事件搜索。我们现在添加了一些Web服务,事件不会自动推送到日历中。自动添加功能不再工作了代码在这里请问尽可能多的问题我在android清单中有权限。我所看到的一切都应该是好的,我把它叫做这里,代码是什么。运行没有错误只是从未在日历中显示

SharedPreferences preferences = PreferenceManager.getDefaultSharedPreferences(getActivity().getApplicationContext());
AutoAddFlag = preferences.getBoolean("auto_calendar_preference", false);
calendarButton.setOnClickListener(new View.OnClickListener() {
    @Override
    public void onClick(View v) {
        if(AutoAddFlag)
            autocreate();
        else
            createEvent();

    }
});

public void autocreate(){
    //need to set the real times
    Calendar beginTime = Calendar.getInstance();

    beginTime.set(2015,6,10,10,10);
    //need to set the real end time
    Calendar endTime = Calendar.getInstance();
    endTime.set(7, 7, 30, 1, 30);

    //create content that will go into the calendar
    ContentValues calEvent = new ContentValues();
    //create ability to insert into the calendar
    ContentResolver cr = this.getActivity().getContentResolver();
    //where/when/id_for_insert/start_time/end_time/time_zone
    //need address/description
    calEvent.put(CalendarContract.Events.CALENDAR_ID,1); // XXX pick)


    calEvent.put(CalendarContract.Events.DTSTART, beginTime.getTimeInMillis());
    calEvent.put(CalendarContract.Events.DTEND, beginTime.getTimeInMillis());
    calEvent.put(CalendarContract.Events.EVENT_TIMEZONE, TimeZone.getDefault().getID());
    calEvent.put(CalendarContract.Events.TITLE, "titorejwl;e");
    calEvent.put(CalendarContract.Events.EVENT_LOCATION, obj.getVenue_name());
    calEvent.put(CalendarContract.Events.DESCRIPTION, obj.getNotes());
    Uri eventsUri = Uri.parse("content://com.android.calendar/events");
    Uri EVENTS_URI = Uri.parse(CalendarContract.Events.CONTENT_URI.toString());
    Uri uri = cr.insert(EVENTS_URI, calEvent);
    //get id for reminders


    Toast.makeText(getActivity(), uri + " was added to the Calendar", Toast.LENGTH_SHORT).show();
    //Toast.makeText(getActivity(), obj.getDescription() + " was added to the Calendar", Toast.LENGTH_SHORT).show();

}

我所知道的是,Android上的整个日历api都有缺陷且不可预测。这句话对你没有帮助,但请放心,你并不是唯一一个这样做的人;)
Android Studio不会插入日历事件
当然不会。安卓工作室是一个IDE。。。唉……谢谢你这么聪明,我喜欢。但发现代码在lg g4上不起作用,所以first guys的评论可能会很有用