Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding events to Calender #88

Open
ghost opened this issue Apr 14, 2015 · 4 comments
Open

Adding events to Calender #88

ghost opened this issue Apr 14, 2015 · 4 comments

Comments

@ghost
Copy link

ghost commented Apr 14, 2015

I am trying to add the events to the calender , but i could not . Not sure where i am going wrong . Please help me in . .

In the manifest File , i have added the below code

<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />

In the class file , i have added the code as follows ,

calender = (ExtendedCalendarView)findViewById(R.id.chargehis_calenderview);

    // Adding events
    ContentValues values = new ContentValues();
    values.put(CalendarProvider.COLOR, Event.COLOR_RED);
    values.put(CalendarProvider.DESCRIPTION, "Sample Description");
    values.put(CalendarProvider.LOCATION, "Sample Location");
    values.put(CalendarProvider.EVENT, "Test Event");

    Calendar cal = Calendar.getInstance();
    TimeZone tz = TimeZone.getDefault();

    //Day julianStartDay = new Day(getActivity(), 25, 2014, 04);
    cal.set(2015, 04, 25, 9, 0);
    int julianDay = Time.getJulianDay(cal.getTimeInMillis(), cal.getTimeZone().getOffset(0));

    values.put(CalendarProvider.START, cal.getTimeInMillis());
    values.put(CalendarProvider.START_DAY, julianDay);

    cal.set(2015, 04, 25, 13, 0);
    int endDayJulian = Time.getJulianDay(cal.getTimeInMillis(),TimeUnit.MILLISECONDS.toSeconds(tz.getOffset(cal.getTimeInMillis())));

    values.put(CalendarProvider.END, cal.getTimeInMillis());
    values.put(CalendarProvider.END_DAY, endDayJulian);

    Uri uri = getContentResolver().insert(CalendarProvider.CONTENT_URI,values);

But i am not seeing the event added to the calender , let me know where i am going wrong .

@tyczj
Copy link
Owner

tyczj commented Apr 15, 2015

you code looks correct, do you get any errors? also you do not need Calendar permissions unless you are writing to the google calendar

@ghost
Copy link
Author

ghost commented Apr 15, 2015

I don't get any errors but the event is not getting added to the Calender . I could not see the Red dot in the CalenderView .
Regarding the Permissions : i tried that thinking it might be the problem , but didn't help

@moutiahub
Copy link

the red dot is probably on 25 may not on april

@NazarAbbas
Copy link

I'm facing same above problem,there is no events showing in calender.please help me

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants