Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/201.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 使用googleapi访问google日历_Android_Google Calendar Api - Fatal编程技术网

Android 使用googleapi访问google日历

Android 使用googleapi访问google日历,android,google-calendar-api,Android,Google Calendar Api,如何在android上使用新api访问google日历? 使用GDataAPI,我可以编写这样的代码: CalendarService myService = new CalendarService("CalendarService"); myService.setUserCredentials("example@gmail.com", "yourPassword"); URL feedUrl = new URL("http://www.google.com/calendar/feeds/def

如何在android上使用新api访问google日历? 使用GDataAPI,我可以编写这样的代码:

CalendarService myService = new CalendarService("CalendarService");
myService.setUserCredentials("example@gmail.com", "yourPassword");
URL feedUrl = new URL("http://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed resultFeed = myService.getFeed(feedUrl, CalendarFeed.class);
Log.d(TAG,"Your calendars:");
for (int i = 0; i < resultFeed.getEntries().size(); i++) {
  CalendarEntry entry = resultFeed.getEntries().get(i);
  Log.d(TAG,entry.getTitle().getPlainText());
}
CalendarService myService=新的CalendarService(“CalendarService”);
myService.setUserCredentials(“example@gmail.com“,“您的密码”);
URL feedUrl=新URL(“http://www.google.com/calendar/feeds/default/allcalendars/full");
CalendarFeed resultFeed=myService.getFeed(feedUrl,CalendarFeed.class);
Log.d(标记“您的日历:”);
for(int i=0;i

但我不能在android上使用这样的代码,因为SAX异常。请告诉我如何以这种方式使用api进行登录和密码授权。

您不能使用v3进行用户名和密码授权,它使用oAuth2

您需要做的是使用OAuth2获取访问令牌,确保为google日历设置了范围。将刷新令牌保存在某个位置,然后您可以访问所有需要的内容