:calendar: A sample and tutorial demonstrating the use of the Google Calendar API


A sample and tutorial demonstrating the use of the Google Calendar API

Getting started

After reading this tutorial, you should be able to have a working Android project that uses the Google Calendar API. This tutorial assumes that you’re using Android Studio, as well as API 22 or later and the Google Play Services.

Google Play Services is a set of APIs to allow app developers to take advantage of existing Google products (like Gmail, Calendar and Maps) in their own mobile applications and possibly enriching the user experience and ability to share content.

Read more about it here.

Project setup

First of all, open Android Studio to create your app. Enter the application name and company domain, like and the IDE will automatically setup the project’s package name.

Click “Next”, target Phone and Tablet and preferably select the latest SDK version (make sure it is API 11 or later!). Then select Blank Activity and finish the wizard.

Now, with the project open on the IDE, open the build.gradle file (make sure it is the module one), now add the following lines to the dependencies block:

compile ''
compile ''
compile ''
compile ''
compile ''

Now right-click the build.gradle file in the file navigator and click “Synchronize buld.gradle”.

Permissions and Manifest File

Now open your AndroidManifest.xml file and add the following code right after the manifest tag.

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />

And add the following code right before closing the application tag:

    android:value="@integer/google_play_services_version" />

On to the next phase, when you will learn to setup the Google Calendar API, to finally make it all work!

API setup

Now, you need to get a SHA1 fingerprint:

keytool -exportcert -alias androiddebugkey -keystore ~/.android/debug.keystore -list -v

Enter the password of your choosing and copy the SHA1 key. This key is gonna be useful throughout the development of your app but you CAN’T use it for production mode.

Go to your Google Developers Console and enable the Calendar API. After the setup is done, click on the “Consent screen” link, enter an email address and product name and save it!

After that, click on the “Credentials” link and press “Create new Client ID”. Select the option “Installed application”, this is the one you need when developing a native mobile app, and also select Android as the installed application type.

Enter the package name you obtained in the Project setup phase, and enter your generated SHA1 fingerprint. Now click “Create Client ID”.

Run the app

Now that you have created the app and connected it to the Calendar API, go to the “Run” menu and click Run app! You can either plug your device to the computer and run the app on it or you can run it on the emulator (we ran it on a Nexus 5 5.1 emulator). Anyway, you gotta have Google Plays services installed in the system (in case you missed it, go to Tools -> Android -> SDK Manager, search for Google Play Services SDK and install it).

If you receive any error until this step, please submit an issue and we’ll try help you as soon as possible.

Usage Flow

Now with the app installed on our device, we’re going to experience the Google Calendar API usage by fetching our existing events from our Google account. If you don’t have a gmail account, please create one.


  • Click on CalendarQuickStart App to launch the app


  • Enter your email and click NEXT


  • Enter your password and click NEXT


  • Click ACCEPT, this will allow the app to fetch your calendar data from your Google account.


  • Click MORE


  • Click NEXT


  • Choose your account and click OK


  • Accept permissions by clicking on OK


  • Existing events are returned in plain text. The CalendarQuickStart app has successfully downloaded your events through.

Desktop Calendar Gmail screenshot

Further Reading for Google Calendar API

If you got hooked and feel like going beyond this tutorial with Calendar integration (creating and updating events from your app, perhaps?), then you should definitely take a look at these links:



See LICENSE file.

Related Repositories



:calendar: A sample and tutorial demonstrating the use of the Google Calendar API ...

Top Contributors

miguelarauj1o rodrigoalvesvieira