5
votes

I am trying to create calendar event in my Titanium App for Android Platform. For that I am using below code, It does't give any error also didn't to create any calendar events

var calendars = Ti.Android.Calendar.selectableCalendars;
        var names =[];
        for (var i = 0; i<calendars.length; i++) {
            names.push(calendars[i].name);
        }

        var calendarDialog = Titanium.UI.createOptionDialog({
            title: 'Select a Calendar',
            options: names,
            cancel:1
        });
        calendarDialog.addEventListener('click', function(e){
            var ci = e.index+1;
            var calendar = Ti.Android.Calendar.getCalendarById(ci);

            var eventBegins = new Date(2011, 12, 26, 12, 0, 0);
            var eventEnds = new Date(2011, 12, 26, 14, 0, 0);
            var hasReminder = true;
            var details = {
                title: 'i m testing',
                description: 'message',
                begin: eventBegins,
                end: eventEnds,
                hasAlarm:true,
                allDay:true
            };

            var event = calendar.createEvent(details);

            if (hasReminder)
            {
                var reminderDetails = {
                    minutes: 10,
                    method: Ti.Android.Calendar.METHOD_ALERT
                };

                event.createReminder(reminderDetails);
            }

            alert('Event was created!');
        });
        calendarDialog.show();

Anyone help me to solve this issue.. My Titanium SDK version is 1.7.5, I have tried this in Android 2.3 Phone

1
Hi, anybody having idea about creating calender eventKarthi Ponnusamy
I dropped your code into a new TiStudio project and it worked just fine. No errors and the event was created in my calendar. I am, however, using the latest 2.1 SDK so you might consider updating.Mark Biek

1 Answers

0
votes

The following link might help you.

https://github.com/codememan/Titanium-Calendar

you need to add the necessary file in your project then you can import and run the Code from the .js file.