简体   繁体   中英

how to integrate google calendar in my android application?

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

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 .

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM