how to integrate google calendar in my android application?

天涯浪子 提交于 2019-12-23 05:29:16

问题


I am trying to integrate google calendar in my app to add my events to google calendar but i do not know how to integrate. please any one could you help me Thanks in advance


回答1:


If you want to use Calendar in your app directly, you can use this GitHub Library that offers a lot of customization:

  1. Caldroid
  2. Android-Week-View

But if you wish to use Calendar, you should work with these intents:

Try this in your code:

Calendar cal = Calendar.getInstance();              
Intent intent = new Intent(Intent.ACTION_EDIT);
intent.setType("vnd.android.cursor.item/event");
intent.putExtra("beginTime", cal.getTimeInMillis());
intent.putExtra("allDay", true);
intent.putExtra("rrule", "FREQ=YEARLY");
intent.putExtra("endTime", cal.getTimeInMillis()+60*60*1000);
intent.putExtra("title", "A Test Event from android app");
startActivity(intent);

Add permission..

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"...>
    <uses-sdk android:minSdkVersion="14" />
    <uses-permission android:name="android.permission.READ_CALENDAR" />
    <uses-permission android:name="android.permission.WRITE_CALENDAR" />
    ...
</manifest>

As for the Google Calendar access, the best way is to use the Google Calendar API.




回答2:


you can use google API For example, your hiking app could automatically add routes into a user's calendar. https://developers.google.com/google-apps/calendar.



来源:https://stackoverflow.com/questions/35030608/how-to-integrate-google-calendar-in-my-android-application

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!