如果您只想打开日历,则可以使用这些组件名称并同时使用它们(如果要支持较旧的手机,则可能必须兼顾两者)
Intent i = new Intent();//Froyo or greater (mind you I just tested this on CM7 and the less than froyo one worked so it depends on the phone...)cn = new ComponentName("com.google.android.calendar", "com.android.calendar.LaunchActivity");//less than Froyocn = new ComponentName("com.android.calendar", "com.android.calendar.LaunchActivity");i.setComponent(cn);startActivity(i);
如果要转到添加事件屏幕(听起来更符合您的目的),请使用以下命令:
//all version of android Intent i = new Intent(); // mimeType will popup the chooser any for any implementing application (e.g. the built in calendar or applications such as "Business calendar" i.setType("vnd.android.cursor.item/event"); // the time the event should start in millis. This example uses now as the start time and ends in 1 hour i.putExtra("beginTime", new Date().getTime()); i.putExtra("endTime", new Date().getTime() + DateUtils.HOUR_IN_MILLIS); // the action i.setAction(Intent.ACTION_EDIT); startActivity(i);
(代码未经测试,是从现有项目复制的)
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)