java - how can i open the calendar from my app? -


i building app android, dont need app have calendar part of it(plus defeat purpose), app allows user listen radio station, , needs option set event to(remember listen radio @ specific time), if app has own calendar event alarms go off if user has app open... pointless. have been looking , cannot find, there way use intent or else open google calendar or other calendar android might have? need put intent(/ other code) in listener have , looks

private view.onclicklistener reminder = new view.onclicklistener() {          @override         public void onclick(view v) {                   // open calendar code goes here.              } }; 

i dont need app pre-fill in field in calendar open it, leave rest user. welcome , thank you

if want open calendar can use , intent either of these component names (you might have cater both if want support older phones)

intent = new intent();  //froyo or greater (mind tested on cm7 , less froyo 1 worked depends on phone...) cn = new componentname("com.google.android.calendar", "com.android.calendar.launchactivity");  //less froyo cn = new componentname("com.android.calendar", "com.android.calendar.launchactivity");  i.setcomponent(cn); startactivity(i); 

if want go add event screen (which sounds better purpose) use like:

 //all version of android  intent = new intent();   // mimetype popup chooser  implementing application (e.g. built in calendar or applications such "business calendar"  i.settype("vnd.android.cursor.item/event");    // time event should start in millis. example uses start time , ends in 1 hour  i.putextra("begintime", new date().gettime());   i.putextra("endtime", new date().gettime() + dateutils.hour_in_millis);   // action  i.setaction(intent.action_edit);  startactivity(i); 

(code untested, copied existing project)


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -