谷歌加入Android邀请

时间:2014-07-21 12:52:00

标签: android google-plus

我刚刚在我的Android应用中使用以下链接http://www.androidhive.info/2014/02/android-login-with-google-plus-account-1/进行Google Plus集成,它运行良好。但当我尝试通过Google plus邀请用户访问我的应用时,我无法做到这一点。是否可以邀请谷歌加朋友加入我的应用程序?

我用它来获取好友列表

@Override
    public void onPeopleLoaded(ConnectionResult status, PersonBuffer personBuffer, String nextPageToken) {
        switch (status.getErrorCode()) {

        case ConnectionResult.SUCCESS:
            try {
                int count = personBuffer.getCount();
                Log.e("", "count : " + count);
                for (int i = 0; i < count; i++) {
                    Log.e("NAME", "" + personBuffer.get(i).getDisplayName());
                }
            } finally {
                personBuffer.close();
            }

            break;

        case ConnectionResult.SIGN_IN_REQUIRED:
            mPlusClient.disconnect();
            mPlusClient.connect();
            break;

        default:
            Log.e("TAG", "Error when listing people: " + status);
            break;
        }
    }

1 个答案:

答案 0 :(得分:1)

要从Android应用分享到Google+,您需要关注此guideline

为您的布局添加分享按钮。

<Button
  android:id="@+id/share_button"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  android:text="Share on Google+"
/>

在您的活动中,配置按钮的OnClickListener,以便在点击时共享。

Button shareButton = (Button) findViewById(R.id.share_button);
shareButton.setOnClickListener(new OnClickListener() {
    @Override
    public void onClick(View v) {
      // Launch the Google+ share dialog with attribution to your app.
      Intent shareIntent = new PlusShare.Builder(this)
          .setType("text/plain")
          .setText("Welcome to the Google+ platform.")
          .setContentUrl(Uri.parse("https://developers.google.com/+/"))
          .getIntent();

      startActivityForResult(shareIntent, 0);
    }
});