android - How can we know that the user clicked the save button in calendar to create an event or the cancel button? -
intent intent = new intent(intent.action_insert) .setdata(events.content_uri) .putextra(calendarcontract.extra_event_begin_time, begintime.gettimeinmillis()) .putextra(calendarcontract.extra_event_end_time, endtime.gettimeinmillis()) .putextra(events.title, title) .putextra(events.description,desc ) .putextra(events.event_location, loc) .putextra(events.availability, events.availability_busy);
i used code adding event.i don't want use insertion using contentvalues because not give user chance select calendar.so how can know user has pressed save or cancel button?plzzzzzz help
startactivityforresult(intent,result_canceled);
as per suggestions used start calendar activity , below onactivityresult callback.
@override public void onactivityresult(int req,int res,intent intent){ if(result_ok==res){ toast.maketext(getapplicationcontext(), "resuming activity",toast.length_long).show(); toast.maketext(getapplicationcontext(),"created event number:"+string.valueof(getlasteventid()), toast.length_long).show(); addreminder(getlasteventid()); } else if(result_canceled==res){ toast.maketext(getapplicationcontext(), "no events added",toast.length_long).show(); } }
now problem on pressing done or cancel,both times toast appears showing "no events added".this means done , cancel returns result_canceled.please check it....
something this:
protected void onactivityresult(int requestcode, int resultcode, intent data) { if(result_ok == resultcode){ //xxxxxxxx } else if (result_canceled == resultcode){ //xxxxxxxx } }
Comments
Post a Comment