Google+ Android分享集成

Google+ 分享
准备工作

你必须创建一个谷歌开发者控制台项目并初始化GoogleApiClient对象

开始将Google+集成到您的Andr​​oid应用
第1步:添加谷歌登入

开始整合谷歌登录的到你的Android应用程序

1 、一个分享按钮添加到您的布局。

2、在你的活动中,配置按钮的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);
 }
});

接下来,你可以建立在这个代码中加入先进的功能,如深层链接或交互式的帖子。

你可能感兴趣的:(Google+ Android分享集成)