Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/208.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android:是否可以在不调用Google日历API或启动本机日历活动的情况下添加日历事件?_Android_Calendar - Fatal编程技术网

Android:是否可以在不调用Google日历API或启动本机日历活动的情况下添加日历事件?

Android:是否可以在不调用Google日历API或启动本机日历活动的情况下添加日历事件?,android,calendar,Android,Calendar,我想问一下,是否可以在不调用Google日历API(需要internet连接)或启动本机日历活动(不需要)的情况下添加日历事件?只需将日历事件添加到设备本机日历中(无需读取、筛选等) 非常感谢您的任何建议是的,可以启动本机日历活动 Intent calendarIntent = new Intent(Intent.ACTION_INSERT, Events.CONTENT_URI); Calendar beginTime = Calendar.getInstance().set(2012

我想问一下,是否可以在不调用Google日历API(需要internet连接)或启动本机日历活动(不需要)的情况下添加日历事件?只需将日历事件添加到设备本机日历中(无需读取、筛选等)


非常感谢您的任何建议

是的,可以启动本机日历活动

Intent calendarIntent = new Intent(Intent.ACTION_INSERT,     Events.CONTENT_URI);
Calendar beginTime = Calendar.getInstance().set(2012, 0, 19, 7, 30);
Calendar endTime = Calendar.getInstance().set(2012, 0, 19, 10, 30);
calendarIntent.putExtra(CalendarContract.EXTRA\u EVENT\u BEGIN\u TIME,beginTime.getTimeInMillis()); calendarIntent.putExtra(CalendarContract.EXTRA\u EVENT\u END\u TIME,endTime.getTimeInMillis()); calendarIntent.putExtra(Events.TITLE,“忍者职业”); calendarIntent.putExtra(Events.EVENT_位置,“秘密道场”)


现在开始上面的活动。希望能有帮助。

我想你要找的是。(另见)

您可以使用它来读取、写入、更新和删除日历事件。尽管您需要日历权限,但:

<uses-permission android:name="android.permission.READ_CALENDAR" />
<uses-permission android:name="android.permission.WRITE_CALENDAR" />


然后,您可以只使用用户日历或创建自己的日历。

但是您的示例将使用预先填充的值启动默认日历应用程序(活动)。