Getting Events from Calendar Provider Android -
i make simple method events calendar provider. events facebook calendar , holidays calendar. why it's not working other calendars google calendar?
public list<eventdata> geteventsfromday(calendar begintime, calendar endtime) { //convert callendar data millis long beginmillis = begintime.gettimeinmillis(); long endmillis = endtime.gettimeinmillis(); //list of events day list<eventdata> allevents = new arraylist<>(); ///////////searching events id day instances table //what want data string[] instancequery = new string[]{ instances._id, instances.begin, instances.end, instances.event_id}; //cursor needed data cursor cursor = instances.query(mcontext.getcontentresolver(), instancequery, beginmillis, endmillis); if (cursor.movetofirst()) { { //save id of every event day eventdata singleevent = new eventdata(); singleevent.setid(cursor.getlong(3)); allevents.add(singleevent); } while (cursor.movetonext()); } //always close cursor!! cursor.close(); ////////// searching details of events events table //what want data string[] eventquery = new string[]{ events._id, events.title, events.event_color, }; (int = 0; < allevents.size(); i++) { //cursor needed data cursor eventcursor = mcontext.getcontentresolver(). query( events.content_uri, eventquery, events._id + " = ? ", new string[] {long.tostring(allevents.get(i).getid())}, null); //convert data cursor if (eventcursor.movetofirst()) { allevents.get(eventcursor.getposition()).settitle(eventcursor.getstring(1)); allevents.get(eventcursor.getposition()).setcolor(eventcursor.getstring(2)); } //always close cursor!! eventcursor.close(); } return allevents; }
the whole aplication here: https://github.com/mulciber55/wombatcalendar
Comments
Post a Comment