如何从Google+ API for Android获取当前位置?

时间:2014-03-14 15:05:54

标签: android google-api google-plus

我需要从Google+ API for Android获取当前位置。

我已经在Google API控制台中完成了所有操作,并将我的应用与客户端ID与SHA1和包名称相关联。

我成功获得了有关用户名,个人资料图片,封面图片,电子邮件等的数据......

但我的位置有问题。我无法获得用户位置。

我使用这个范围:

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作为位置。

有谁知道如何解决这个问题?

1 个答案:

答案 0 :(得分:1)

看起来currentLocation值不是currently available through the API