我在本教程后使用Google+ API成功登录了我的Google Plus帐户:
Android Login with Google Plus Account
并获得了一些用户信息(姓名,电子邮件,以及个人资料网址,图片等)。
我遇到的问题是我无法获得用户的活动(我的意思是用户"墙上的最后一篇文章")。 我知道使用Google Plus API我只能参加公共活动,但我甚至无法获得这些活动。 我使用的代码是
// This sample assumes a client object has been created.
// To learn more about creating a client, check out the starter:
// https://developers.google.com/+/quickstart/java
Plus.Activities.List listActivities = plus.activities().list("me", "public");
listActivities.setMaxResults(5L);
// Execute the request for the first page
ActivityFeed activityFeed = listActivities.execute();
// Unwrap the request and extract the pieces we want
List<Activity> activities = activityFeed.getItems();
// Loop through until we arrive at an empty page
while (activities != null) {
for (Activity activity : activities) {
System.out.println("ID " + activity.getId() + " Content: " +
activity.getObject().getContent());
}
// We will know we are on the last page when the next page token is null.
// If this is the case, break.
if (activityFeed.getNextPageToken() == null) {
break;
}
// Prepare to request the next page of activities
listActivities.setPageToken(activityFeed.getNextPageToken());
// Execute and process the next page request
activityFeed = listActivities.execute();
activities = activityFeed.getItems();
}
我从此地址获得了Google+ API官方网站:
Google+ Platform: Activities: list
当我尝试编译并运行时,我收到以下错误消息:
Error:Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.
Error:(207, 21) error: cannot find symbol class Activities
Error:(207, 55) error: cannot find symbol variable plus
Error:(211, 17) error: cannot find symbol class ActivityFeed
Error:(214, 17) error: cannot find symbol class List
Error:(219, 60) error: cannot find symbol method getId()
Error:(220, 41) error: cannot find symbol method getObject()
任何人都可以帮助我吗? 非常感谢。
答案 0 :(得分:0)
您使用的示例是使用https://github.com/googleplus/gplus-quickstart-java.git中的(google-api-services-plus..jar)API,而您的应用程序使用的是Android Google Messaging Services API。
我猜你的Plus导入是com.google.android.gms.plus.Plus吗? (这是你想在Android上使用的)
您可能想要使用Plus.MomentsApi API,请参阅https://developers.google.com/+/mobile/android/app-activities。