Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to develop an application for Android which uses Google Calendar API

I just started doing some Android app development, and I decided I'm going to write an app to work with Google Calendar.

The first problem that came to me is that I can't add any Gmail account on the emulator. When I go to settings -> accounts, I can only add an Exchange account.

This raises a question how should I develop such application. I know that I should mock the API while I'm running tests, but how am I supposed to run the app on the emulator?

Should I just test it on mocked API with JUnit and then run it on production phone?

like image 244
Jakub Arnold Avatar asked Nov 14 '10 17:11

Jakub Arnold


2 Answers

As for the emulator set up for a Google account, well, it depends on the Android version you have in your AVD: for example for 2.2, go to Settings/Accounts & Sync, click on Add account and Google, etc.

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

Please note: there is not yet an official Android SDK API for the Calendar access.

like image 127
StanislavK Avatar answered Oct 21 '22 05:10

StanislavK


There is a good example of accessing Google Calendar Data API from Android using the Google API Client Library for Java at calendar-v2-atom-android-sample. There are detailed instructions there for setting up the proper package:

  • Window > Android SDK and AVD Manager
    • Follow instructions to install Package "Google API's by Google Inc., Android API 8"
    • Follow instructions to create a new Android Virtual Device based on target "Google API's (Google Inc.) - API Level 8"
    • Click "Start..." (wait a while...)
    • On home screen in emulator, click Menu button, Settings
    • Click on "Accounts and Sync"
    • Click on "Add Account"
    • Click "Google" and follow instructions

Disclaimer: I am an owner of the Google API Client Library for Java project.

like image 43
Yaniv Inbar Avatar answered Oct 21 '22 04:10

Yaniv Inbar