本文整理匯總了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();
}
}