如何从我的应用程序打开日历?

如何从我的应用程序打开日历?,第1张

如何从我的应用程序打开日历

如果您只想打开日历,则可以使用这些组件名称并同时使用它们(如果要支持较旧的手机,则可能必须兼顾两者)

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);

(代码未经测试,是从现有项目复制的)



欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5615560.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-15
下一篇 2022-12-15

发表评论

登录后才能评论

评论列表(0条)

保存