android - How to get national holidays of selected country -
i'm making app can select country list. when pick country, appears list of national holidays of country.
i've seen calendarprovider , google calendar v3. seem provide current user calendar.
how national holidays want? suggestion helped me
update:
i've found this post can list holiday using json. in example, country code defined calendar id (pt_br.brazilian#holiday@group.v.calendar.google.com)
don't see docs write this.
found calendar id (en.usa#holiday@group.v.calendar.google.com).
is possible use way? if yes, can calendar id?
problem solved using google calendar api v3. idea found this post. holiday can default holiday calendar of google.
the id list of default holiday calendar can found here, support 40 country.
a piece of code handle permission , holiday list:-
com.google.api.services.calendar.calendar client = null; credential = googleaccountcredential.usingoauth2(mcontext, calendarscopes.calendar); credential.setselectedaccountname(mlist.get(0)); client = getcalendarservice(credential); { 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.newcompatibletransport(), new gsonfactory(), credential).build(); }
Comments
Post a Comment