• After 15+ years, we've made a big change: Android Forums is now Early Bird Club. Learn more here.

Apps Getting calendar events

dhanala1710

Lurker
May 26, 2013
1
0
This is what I am trying to do. I want to build a app for a particular person and have a module inside the application which would populate all the events/shows that the person is scheduled to perform/performed. I have three approaches in mind - one is google api, another is android calendar and the third is using facebook page of that person. Which one would you think is the best approach? thank you guys.
 
Please check here: Calendar Provider | Android Developers

Sample codes for getting events

Cursor instance_cur = null;

//selection
String instance_selection =

"("+Instances.BEGIN+"<"+now+ ")"+
"and" + "("+Instances.END+">"+now+ ")" ;

String[] event_projection = new String[] {
Instances.TITLE, //0
Instances.CALENDAR_DISPLAY_NAME, //1
Instances.BEGIN, //2
Instances.END, //3
Instances.ALL_DAY, //4
Instances.EVENT_LOCATION,//5

};

//find events in a week
Uri.Builder builder = Instances.CONTENT_URI.buildUpon();
ContentUris.appendId(builder, now- DateUtils.WEEK_IN_MILLIS);
ContentUris.appendId(builder, now+ DateUtils.WEEK_IN_MILLIS);

try{

instance_cur = cr.query(builder.build(), event_projection, instance_selection, null, null);

while (instance_cur.moveToNext()) {
String title = instance_cur.getString(0);
String calendarName = instance_cur.getString(1);
Date beginTime = new Date(instance_cur.getLong(2));
Date endTime = new Date(instance_cur.getLong(3));
String eventLocation = instance_cur.getString(5);

}
}catch(Exception e)
{

}finally {

if( instance_cur != null && !instance_cur.isClosed() )
instance_cur.close();
}
}
 
Upvote 0

BEST TECH IN 2023

We've been tracking upcoming products and ranking the best tech since 2007. Thanks for trusting our opinion: we get rewarded through affiliate links that earn us a commission and we invite you to learn more about us.

Smartphones