- c - 在位数组中找到第一个零
- linux - Unix 显示有关匹配两种模式之一的文件的信息
- 正则表达式替换多个文件
- linux - 隐藏来自 xtrace 的命令
我搜索了很多,但仍然没有找到解决方案。Plus.PeopleApi.getCurrentPerson() 总是返回 null。我得到了调试 SHA1 并发布了 SHA1。它们都作为具有正确包名称的 OAuth 2.0 客户端 ID 添加到控制台。 (遗憾的是,我不能发布图片)这是我的 GoogleApiClient:
private GoogleApiClient buildGoogleApiClient() {
return new GoogleApiClient.Builder(getContext())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(new Scope(Scopes.PROFILE))
.addScope(new Scope(Scopes.PLUS_LOGIN))
.build();
}
很简单。我从 Fragment 的 onCreateView() 调用它。然后我试图让当前的人:
@Override
public void onConnected(Bundle bundle) {
Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
String personName = currentPerson.getDisplayName();
String personGooglePlusProfile = currentPerson.getUrl();
}
而且总是空的。 mGoogleApiClient 工作正常,它连接,它不为空,但仍然如此。在 console->Apis Google+ API 中启用,但在“使用”选项卡中没有任何请求。
我已经尝试了我能找到的所有解决方案,但没有任何帮助。我正在使用 geny 模拟器运行该应用程序。请帮助我,给我任何想法。
添加:这是我几乎完整的 Fragment 类:
public class AuthorizationFragment2 extends Fragment implements
GoogleApiClient.ConnectionCallbacks,
GoogleApiClient.OnConnectionFailedListener,
View.OnClickListener,
ResultCallback {
private static final String KEY_IS_RESOLVING = "is_resolving";
private static final String KEY_SHOULD_RESOLVE = "should_resolve";
/* Request code used to invoke sign in user interactions. */
protected static final int RC_SIGN_IN = 0;
/* GP Is there a ConnectionResult resolution in progress? */
private boolean mIsResolving = false;
/* GP Should we automatically resolve ConnectionResults when possible? */
private boolean mShouldResolve = false;
private GoogleApiClient mGoogleApiClient;
/* View to display current status (signed-in, signed-out, disconnected, etc) */
private TextView mStatus;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater,
@Nullable ViewGroup container,
@Nullable Bundle savedInstanceState) {
if (savedInstanceState != null) {
mIsResolving = savedInstanceState.getBoolean(KEY_IS_RESOLVING);
mShouldResolve = savedInstanceState.getBoolean(KEY_SHOULD_RESOLVE);
}
mGoogleApiClient = buildGoogleApiClient();
View view = inflater.inflate(R.layout.authorization_view, container, false);
// Register onClickListener for gp_login_button
view.findViewById(R.id.gp_login_button).setOnClickListener(this);
view.findViewById(R.id.sign_out_button).setOnClickListener(this);
mStatus = (TextView) view.findViewById(R.id.mStatus);
return view;
}
@Override
public void onStart() {
super.onStart();
mGoogleApiClient.connect();
}
@Override
public void onStop() {
super.onStop();
mGoogleApiClient.disconnect();
}
@Override
public void onSaveInstanceState(Bundle outState) {
super.onSaveInstanceState(outState);
outState.putBoolean(KEY_IS_RESOLVING, mIsResolving);
outState.putBoolean(KEY_SHOULD_RESOLVE, mShouldResolve);
}
@Override
public void onConnected(Bundle bundle) {
Plus.PeopleApi.loadVisible(mGoogleApiClient, null).setResultCallback(this);
// It is allways null
if (Plus.PeopleApi.getCurrentPerson(mGoogleApiClient) != null) {
Person currentPerson = Plus.PeopleApi.getCurrentPerson(mGoogleApiClient);
// Retrieve Person's information
}
updateUI(true);
}
@Override
public void onConnectionSuspended(int i) {
Log.d(MainActivity.LOG_TAG, "onCOnnectionSuspended()");
}
@Override
public void onConnectionFailed(ConnectionResult connectionResult) {
if(!mIsResolving && mShouldResolve) {
if (connectionResult.hasResolution()) {
try {
// It calls the Activity's onActivityResult()
connectionResult.startResolutionForResult(getActivity(), RC_SIGN_IN);
mIsResolving = true;
} catch (IntentSender.SendIntentException e) {
mIsResolving = false;
mGoogleApiClient.connect();
}
} else {
// Could not resolve the connection result, show the user an
// error dialog.
showErrorDialog(connectionResult);
}
} else {
// Show the signed-out UI
updateUI(false);
}
}
private GoogleApiClient buildGoogleApiClient() {
return new GoogleApiClient.Builder(getActivity().getApplicationContext())
.addConnectionCallbacks(this)
.addOnConnectionFailedListener(this)
.addApi(Plus.API)
.addScope(Plus.SCOPE_PLUS_PROFILE)
.addScope(Plus.SCOPE_PLUS_LOGIN)
.build();
}
/**
* This called only from Activity's onActivityResult() with requestCode == RC_SIGN_IN
*/
protected void connect(int resultCode) {
// If the error resolution was not successful we should not resolve further.
if (resultCode != Activity.RESULT_OK) {
mShouldResolve = false;
}
mIsResolving = false;
mGoogleApiClient.connect();
}
}
和 list :
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="somepackage" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<uses-permission android:name="android.permission.USE_CREDENTIALS" />
<application
android:allowBackup="true"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</manifest>
对于一些编辑错误,我们深表歉意。
最佳答案
我找到了解决方案。它与 fragment 和 SHA1 key 无关。这是关于包名。当我创建项目时,IDE 将包目录设为“somepackage.app”,这不是我需要的,我将其更改为“somepackage”。一切正常,除了 google api。 Gradle 在其配置文件中保存了“applicationId somepackage.app”,我相信它会覆盖 list 的包名称。没有错误,没有连接,什么都没有。我花了大约 15 个小时,我相信我很愚蠢。
关于android - Plus.PeopleApi.getCurrentPerson() 返回 null,不再返回,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32357293/
我很确定我错过了一些东西,但我找不到(即谷歌)为 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+
我是一名优秀的程序员,十分优秀!