- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
当我尝试使用 Plus 的 People Api 访问用户的基本个人资料信息时,我收到了很多关于我的应用程序崩溃的报告。
这是我的 GoogleApiClient 设置
GoogleSignInOptions gso = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestEmail()
.requestScopes(new Scope(Scopes.PROFILE))
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestIdToken(<id_token>)
.requestProfile()
.build();
mGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, gso)
.addApi(Plus.API)
.addConnectionCallbacks(this)
.build();
在此行获取 IllegalStateException:
Person person = Plus.PeopleApi.getCurrentPerson(mGoogleApiClientPlus)
java.lang.IllegalStateException:GoogleApiClient 有一个可选的 Plus.API 并且没有连接到 Plus。使用 GoogleApiClient.hasConnectedApi(Plus.API) 保护此调用。
只有在 google 登录返回登录用户后才会调用此代码。那为什么plus api连接不上呢?
最佳答案
protected synchronized void buildGoogleApiClient() {
// Configure sign-in to request the user's ID, email address, and basic profile.
// ID and basic profile are included in DEFAULT_SIGN_IN.
gGoogleSignInOptions = new GoogleSignInOptions.Builder(GoogleSignInOptions.DEFAULT_SIGN_IN)
.requestScopes(new Scope(Scopes.PROFILE))
.requestScopes(new Scope(Scopes.PLUS_LOGIN))
.requestProfile()
.requestEmail()
.build();
// Build a GoogleApiClient with access to the Google Sign-In API
// and the options specified by gGoogleSignInOptions.
gGoogleApiClient = new GoogleApiClient.Builder(this)
.enableAutoManage(this /* FragmentActivity */, this /* OnConnectionFailedListener */)
.addApi(Auth.GOOGLE_SIGN_IN_API, mGoogleSignInOptions)
.addApi(Plus.API)
.build();
}
@Override
public void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Result returned from launching the Intent from GoogleSignInApi.getSignInIntent(...);
if (requestCode == RC_SIGN_IN) {
if (resultCode == Activity.RESULT_OK) {
// Google+
if (gGoogleApiClient.hasConnectedApi(Plus.API))
Person person = Plus.PeopleApi.getCurrentPerson(gGoogleApiClient);
else
Log.e("TAG", "Google+ not connected");
GoogleSignInResult result = Auth.GoogleSignInApi.getSignInResultFromIntent(data);
handleSignInResult(result);
} else
Log.e("TAG", "Result Cancelled");
}
}
关于android - GoogleApiClient 有一个可选的 Plus.API,并且没有连接到带有 Play Services 8.3 中引入的新 Google 标志的 Plus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34353674/
我很确定我错过了一些东西,但我找不到(即谷歌)为 Google Plus 创建测试帐户的可能性。 但是,肯定不允许创建虚假用户帐户进行测试,那么,如何使用多个(我的)帐户测试我的 G+ 应用程序? 最
有没有办法查看与 Google Plus 共享您的网站的人的列表(即点击特定 URL 加一按钮的人)? 最佳答案 点击 +1 按钮与分享并不完全相同(例如作为事件的一部分),但您确实可以使用 Goog
所以我试图用我的 sqlite 数据库中的行填充一个对象,如下所示: - (id) initWithSQLite:(sqlite3_stmt *)row andDatabase:(Database*)
R有没有+=的概念? (加等号)或 ++ (plus plus) 像 c++/c#/others 一样吗? 最佳答案 不,它没有,请参阅:R Language Definition: Operator
R有没有+=的概念? (加等号)或 ++ (plus plus) 像 c++/c#/others 一样吗? 最佳答案 不,它没有,请参阅:R Language Definition: Operator
假设我有一个在线购物系统,并且有许多用户注册了它。我想要一个功能,当我添加新产品或对特定产品进行促销时,我的 Google+ 页面会更新,因为产品的详细信息会自动发布在那里。它只会用于后台办公目的。
我经营一个博客并使用 Google Plus 作为推广工具,在 G+ 上发布每次更新。由于我有数百名关注者,我的 G+ 帖子经常有几条评论:我想在我的博客上展示它们! 我知道有一些工具可以根据 G+
链接:https://sites.google.com/site/oauthgoog/Home/emaildisplayscope 在上面的链接中,我添加了电子邮件范围 https://www.goo
在这个简单的脚本中我需要你的一点帮助。我正在尝试创建一个通过阅读 Windows 标题来运行“taskkill”的脚本,但我不知道如何让它在 C++ 中运行。据我所知,批量处理将非常容易 system
map mp; 我能看懂下面的代码: mp[1] = 1; mp[2] = 2; 但这有什么意义呢? mp[3]++; 不设置 mp[3] = n;(n 可以是整数)。 最佳答案 当 map 的 op
每当我需要从缓存中检索数据时,我都会使用 FromCache() 方法。 我没有设置任何默认缓存策略,而是使用默认情况下使用的任何 EF plus。 默认的缓存持续时间是多少?等一下?还是无限? 最佳
我正在我的应用程序中实现 google plus。我想在用户共享消息后实现回调函数。请让我知道在点击 google plus 中的共享按钮后是否可以实现回调。 提前致谢 普拉塔普 最佳答案 通过设置共
我有一个使用 Google+ API 列出您圈子中的用户的应用程序。这很好用,除了一件事:API 没有说明用户是否有图片,或者图片是否只是占位符(蓝色剪影)。 https://developers.g
是否可以将 Google 社区嵌入网站页面? 这样,我们的客户既可以从我们网站的内容和所有其他功能中受益,又可以使用 Google 社区进行协作。 理想情况下,我想抓取一个 Javascript 代码
我在 Google Plus 上有大量相册。我正在寻找一种有效的方式来下载它们。如果我将它们放在 Google Drive 上,我可以使用 skicka ,它有一些烦恼,但总体效果很好。 我正在寻找一
我正在建立一个网站,我想允许谷歌登录。我不希望我的客户再次将他们的个人资料图片上传到我的网站。我有一些关于如何使用 facebook 进行操作的线索,但是一旦用户通过 Google 帐户进行身份验证,
我想在我的网站上显示我的 facebook、twitter、linkedIn、google+ 页面的事件提要。对于 facebook 和 twitter,我通过引用他们的开发者网站(附图片)来获取提要
关闭。这个问题需要更多focused .它目前不接受答案。 想改善这个问题吗?更新问题,使其仅关注一个问题 editing this post . 8年前关闭。 Improve this questi
网上有许多关于如何从 Notepad Plus Plus (NPP) 运行文件的示例。但是它们都没有考虑到当前工作目录是 NPP 可执行文件的位置,而不是文件的位置这一事实。 通常他们是这样的: cm
使用 VIM 编辑文件我可以轻松地复制和粘贴文件的名称(或完整路径) 我正在努力(要了解我对 VIM 的意思,您可以看到: this question 或 wiki ); 是否有使用 Notepad+
我是一名优秀的程序员,十分优秀!