Pages

Thursday, 20 December 2012

open calender to add event from android application


here are two ways to pass the start time and end time  values:::

long startTime = System.currentTimeMillis() -  24*1000 * 60 * 60;
  long endTime = System.currentTimeMillis() + 48*1000 * 60 * 60 * 2;
              (or)

Date date=(new SimpleDateFormat("MM/dd/yyyy hh:mm aa")).parse("12/23/2012 07:00 am");
                                      long startTime=date.getTime();
       Date date2=(new SimpleDateFormat("MM/dd/yyyy hh:mm aa")).parse("12/22/2012 08:30 am");
                                       long endTime=date2.getTime();



Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("title", "Some title");
intent.putExtra("description", "Some description");
intent.putExtra("beginTime", startTime);
intent.putExtra("endTime", endTime);
startActivity(intent);