Can I add event to calendar without letting user know in android? -


i want add event native calendar using below code. , working fine.

simpledateformat formatter = new simpledateformat("yyyy/mm/dd hh:mm");                 final calendar cal = calendar.getinstance();                 try {                     cal.settime(formatter.parse(datetime));                     eventdate = cal.get(calendar.year)+"/"+cal.get(calendar.month)+"/"+cal.get(calendar.day_of_month)+" "+cal.get(calendar.hour_of_day)+":"+cal.get(calendar.minute);                     log.e("event date",eventdate);                 }                  catch (parseexception e) {                     e.printstacktrace();                 }                 intent intent = new intent(intent.action_edit);                 intent.settype("vnd.android.cursor.item/event");                 intent.putextra("begintime", cal.gettimeinmillis());                 intent.putextra("allday", true);                 intent.putextra("endtime", cal.gettimeinmillis()+60*60*1000);                 intent.putextra("title", title);                 intent.putextra("description",desc);                 c.startactivity(intent); 

this opens screen asks me save event. , when click on save, saves event calendar. below screenshot that.

enter image description here

now, want add event directly native calendar, without showing above screen. there way that?

you can refer below code add events in calender.

string global_date_format = "yyyy-mm-dd hh:mm:ss"; string gamedate="2015-07-12 01:10:00";         date startdate = dateconstants.getdatefromstring(                 gamedate,global_date_format);         long enddate = startdate.gettime()                 + (ptgconstantmethod.validateinteger(game                         .getgame_duration()) * 1000);          contentvalues event = new contentvalues();         event.put("calendar_id", 1);         event.put("title", "game#" + game.getid());         event.put("description", game.getlocation());         event.put("eventlocation", game.getlocation());         event.put("eventtimezone", timezone.getdefault().getid());         event.put("dtstart", startdate.gettime());         event.put("dtend", enddate);          event.put("allday", 0); // 0 false, 1 true         event.put("eventstatus", 1);         event.put("hasalarm", 1); // 0 false, 1 true          string eventuristring = "content://com.android.calendar/events";         uri eventuri = context.getapplicationcontext()                 .getcontentresolver()                 .insert(uri.parse(eventuristring), event);         long eventid = long.parselong(eventuri.getlastpathsegment());  // if reminder need set               int minutes=120;               // add reminder event             contentvalues reminders = new contentvalues();             reminders.put("event_id", eventid);             reminders.put("method", "1");             reminders.put("minutes", minutes);              string reminderuristring = "content://com.android.calendar/reminders";             context.getapplicationcontext().getcontentresolver()             .insert(uri.parse(reminderuristring), reminders); 

Comments

Popular posts from this blog

python - Healpy: From Data to Healpix map -

c - Bitwise operation with (signed) enum value -

xslt - Unnest parent nodes by child node -