-2

The requirement is to choose a country from a dropdown and display the list of holidays for the country chosen. Please let me know if there are any APIs that accomplish this.

karthik
  • 181
  • 2
  • 3
  • 10

2 Answers2

3

You don't need to use any third party API for it, you can do it with google Calendar API like this

com.google.api.services.calendar.Calendar client = null;
    credential = GoogleAccountCredential.usingOAuth2(mContext, CalendarScopes.CALENDAR);
    credential.setSelectedAccountName(mList.get(0));
    client = getCalendarService(credential);
    do {
        com.google.api.services.calendar.model.Events events;
        events = client.events().list("en.usa#holiday@group.v.calendar.google.com").setPageToken(pageToken).execute();
        onHolidayChecked(events.getItems()); //result return here (events.getItems())
        pageToken = events.getNextPageToken();
    } while (pageToken != null);

 private com.google.api.services.calendar.Calendar getCalendarService(GoogleAccountCredential credential) {
    return new com.google.api.services.calendar.Calendar.Builder(AndroidHttp.newCompatibleTrans port(), new GsonFactory(), credential).build();
}
Akshay Panchal
  • 695
  • 5
  • 15
  • What is pagetoken here.. and also i don't have the method onHolidayChecked. – karthik Mar 16 '17 at 11:25
  • define pageToken String, and onHolidayChecked() is method which will be called when user clicks on any item,so you can replace it with your method if you want, also please mark answer as accepted if it worked :) – Akshay Panchal Mar 16 '17 at 12:01
0

Only solution I found is that to either add it statically in your string.xml

or

Try this API which google provides

1) Register a project at https://code.google.com/apis/console
2) Generate a Simple API Access key
3) Ensure Calendar API is activated under services.

Read more at https://developers.google.com/google-apps/calendar/firstapp

checkout this sample

Community
  • 1
  • 1
Rissmon Suresh
  • 13,173
  • 5
  • 29
  • 38