当前位置: 首页>>代码示例>>Java>>正文


Java PlusClient.getCurrentPerson方法代码示例

本文整理汇总了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();
    }
}
 
开发者ID:someshk,项目名称:samsung-chord-hackathon,代码行数:19,代码来源:SignInActivity.java

示例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();
	}
}
 
开发者ID:vicfryzel,项目名称:gplus-photohunt-client-android,代码行数:46,代码来源:BaseActivity.java


注:本文中的com.google.android.gms.plus.PlusClient.getCurrentPerson方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。