【发布时间】:2014-03-14 15:05:53
【问题描述】:
我需要从 Google+ API for Android 获取当前位置。
我已经在 Google API 控制台中完成了所有操作,并将我的应用与带有 SHA1 的客户端 ID 和包名称相关联。
我成功获取了关于用户名、头像、封面图片、电子邮件的几乎数据...
但我的位置有问题。我无法获取用户位置。
我使用这个范围:
mGoogleApiClient = new GoogleApiClient.Builder(this)
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this).addApi(Plus.API, null)
.addScope(Plus.SCOPE_PLUS_PROFILE).build();
我使用此代码获取个人资料信息:
String personName = currentPerson.getDisplayName();
String userId = currentPerson.getId();
String personPhotoUrl = currentPerson.getImage().getUrl();
String personGooglePlusProfile = currentPerson.getUrl();
String email = Plus.AccountApi.getAccountName(mGoogleApiClient);
String location = currentPerson.getCurrentLocation();
String coverPhoto = currentPerson.getCover().getCoverPhoto().getUrl();
我成功获取了所有这些数据,但我得到了 null 作为位置。
有人知道如何解决这个问题吗?
【问题讨论】:
-
您是否将 ACCESS_COARSE_LOCATION 和 ACCESS_FINE_LOCATION 添加到清单中?
-
不,我没有。我会试试看的。
-
我添加了这些权限,但它又是空的。
-
@Zookey:这个问题解决了吗?您是否获得了未设置封面照片的用户的封面照片 URL?我有一个奇怪的问题:stackoverflow.com/questions/24995808/…
标签: android google-api google-plus