Android Studio will not insert calendar event

I am writing an event search. We have added some web services that will no longer be automatically loaded into the calendar. The auto add feature no longer works. Code, please ask as many questions as possible. I have permissions in android manifest. all i see should be good to go where i call it and what the code is currently. Doesn't run any errors that never appear on the calendar

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();

}

      

+3
java android android-event android-calendar


source to share


No one has answered this question yet

Check out similar questions:

3606
Close / hide Android soft keyboard
3295
Why is the Android emulator so slow? How can we speed up the development of an Android emulator?
3288
Correct use cases for Android UserManager.isUserAGoat ()?
2609
Is there a unique identifier for an Android device?
2510
How to persist android activity state by persisting instance state?
2097
Is there a way to run Python on Android?
1844
What is "Context" on Android?
1345
Where can I put the "assets" folder in Android Studio?
1214
Rename package in Android Studio
1206
What is Gradle in Android Studio?



All Articles
Loading...
X
Show
Funny
Dev
Pics