本文整理汇总了Java中com.google.android.gms.plus.PlusClient.getCurrentPerson方法的典型用法代码示例。如果您正苦于以下问题:Java PlusClient.getCurrentPerson方法的具体用法?Java PlusClient.getCurrentPerson怎么用?Java PlusClient.getCurrentPerson使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.android.gms.plus.PlusClient
的用法示例。
在下文中一共展示了PlusClient.getCurrentPerson方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onSignedIn
import com.google.android.gms.plus.PlusClient; //导入方法依赖的package包/类
@Override
public void onSignedIn(PlusClient plusClient) {
mSignInStatus.setText(getString(R.string.signed_in_status));
// We can now obtain the signed-in user's profile information.
Person currentPerson = plusClient.getCurrentPerson();
if (currentPerson != null) {
String greeting = getString(R.string.greeting_status, currentPerson.getDisplayName());
mSignInStatus.setText(greeting);
// Add the user name in the Preferences
AppPrefs.setUserAccountName(SignInActivity.this, currentPerson.getDisplayName());
Intent reservationsIntent = new Intent(SignInActivity.this, NavDrawerMainActivity.class);
startActivity(reservationsIntent);
finish();
} else {
resetAccountState();
}
}
示例2: onSignedIn
import com.google.android.gms.plus.PlusClient; //导入方法依赖的package包/类
/**
* Invoked when the {@link PlusClientFragment} delegate has successfully
* authenticated the user.
*
* @param plusClient
* The connected PlusClient which gives us access to the Google+
* APIs.
*/
@Override
public void onSignedIn(PlusClient plusClient) {
if (plusClient.isConnected()) {
mPlusPerson = plusClient.getCurrentPerson();
// Retrieve the account name of the user which allows us to retrieve
// the OAuth access
// token that we securely pass over to the PhotoHunt service to
// identify and
// authenticate our user there.
final String name = plusClient.getAccountName();
// Asynchronously authenticate with the PhotoHunt service and
// retrieve the associated
// PhotoHunt profile for the user.
mAuthTask = new AsyncTask<Object, Void, User>() {
@Override
protected User doInBackground(Object... o) {
return AuthUtil.authenticate(BaseActivity.this, name);
}
@Override
protected void onPostExecute(User result) {
if (result != null) {
setAuthenticatedProfile(result);
executePendingActions();
update();
} else {
setAuthenticatedProfile(null);
mPlus.signOut();
}
}
};
mAuthTask.execute();
}
}