小编dx3*_*906的帖子

如何在Android中使用Google登录获取性别等个人资料?

我想将谷歌登录集成到我的应用程序,当用户首次登录我将创建一个帐户绑定到此,所以我需要一些配置文件,如性别,区域设置等,我尝试作为谷歌登录文档和快速-start示例显示:

GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
            .requestEmail()
            .build();

    mGoogleApiClient = new GoogleApiClient.Builder(this)
            .enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
            .addApi(Auth.GOOGLE_SIGN_IN_API, gso)
            .build();
Run Code Online (Sandbox Code Playgroud)

点击登录时我会打电话:

  Intent signInIntent = Auth.GoogleSignInApi.getSignInIntent(mGoogleApiClient);
    startActivityForResult(signInIntent, RC_SIGN_IN);
Run Code Online (Sandbox Code Playgroud)

登录成功后,我可以在onActivityResult中获取数据结构GoogleSignInResult,来自GoogleSignInResult我可以获得一个GoogleSignInAccount,其中只包含DisplayName,email和id.但是在https://developers.google.com/apis-explorer/#p/中,我可以获得性别,语言环境等个人资料.我错过了什么吗?

我试过google plus api,似乎我可以得到我想要的东西.但是不知道如何使用,doc说创建客户端是这样的:

mGoogleApiClient = new GoogleApiClient.Builder(this)
            .addConnectionCallbacks(this)
            .addOnConnectionFailedListener(this)
            .addApi(Plus.API)
            .addScope(new Scope(Scopes.PLUS_LOGIN))
            .addScope(new Scope(Scopes.PLUS_ME))
            .build();
Run Code Online (Sandbox Code Playgroud)

但是当我使用它时,单击登录按钮将导致应用程序崩溃.

更新: 更新到新版Google的问题登录使用Google Services 3.0.0时丢失api_key /当前密钥

android google-plus-signin google-signin

25
推荐指数
2
解决办法
2万
查看次数

android aapt错误:无layout_constraintLeft_toLeftOf

当我使用aapt comandline为新创建的android项目生成.R文件时,它表明

No resource identifier found for attribute 'layout_constraintLeft_toLeftOf' in package 'com.test.androidpack'

那么,如何在aapt命令行中包含约束布局?

我的命令行是如下: aapt package -f ^ -M C:\Users\Administrator\Desktop\test\AndoidPack\app\src\main\AndroidManifest.xml ^ -I D:\Android\Sdk\platforms\android-27\android.jar ^ -S C:\Users\Administrator\Desktop\test\AndoidPack\app\src\main\res ^ -J gen ^ -m 我试图添加-I xxxx\constraint-layout-1.1.1.aar-j constraint-layout-1.1.1.aar所有失败

android aapt android-resources

1
推荐指数
1
解决办法
2852
查看次数