I am calling the following function to add a Calendar event (taken largely from roman10):
private void addEvent() {
Intent l_intent = new Intent(Intent.ACTION_EDIT);
l_intent.setType("vnd.android.cursor.item/event");
l_intent.putExtra("title", "roman10 calendar tutorial test");
l_intent.putExtra("description", "This is a simple test for calendar api");
l_intent.putExtra("eventLocation", "@home");
l_intent.putExtra("beginTime", System.currentTimeMillis());
l_intent.putExtra("endTime", System.currentTimeMillis() + 1800*1000);
l_intent.putExtra("allDay", 0);
l_intent.putExtra("eventStatus", 1);
l_intent.putExtra("visibility", 0);
l_intent.putExtra("transparency", 0);
l_intent.putExtra("hasAlarm", 1);
try {
startActivity(l_intent);
} catch (Exception e) {
Toast.makeText(this.getApplicationContext(), "Sorry, no compatible calendar is found!", Toast.LENGTH_LONG).show();
}
}
After the completion of this intent, I would like to manually refresh my list activity, which simply holds a list of all the user’s events (I want it to instantly reflect the changes). Does anyone know of a way to do this? Is there any particular function which is called upon the completion of this intent that I can modify?
Your best bet is to use startActivityForResults(Intent, id)
Then add this function to your activity: