如何在google plus上分享帖子?

时间:2013-10-13 17:27:26

标签: android google-plus google-api-java-client

我会在google plus上分享一个帖子,而不是应用程序安装在手机上。我刚看到这个解决方案:

Intent shareIntent=new Intent(Intent.ACTION_SEND);
                shareIntent.setType("text/plain");
                shareIntent.putExtra(Intent.EXTRA_TEXT,"your text here");
                shareIntent.putExtra(Intent.EXTRA_SUBJECT, "post title");
                startActivity(Intent.createChooser(shareIntent, "Share..."));

但是这个解决方案可以在手机中安装google plus的应用程序。 如果没有应用程序,我可以分享。任何人都可以建议我如何做到这一点?

1 个答案:

答案 0 :(得分:1)

如果您想查看,Google Play服务中的PlusShare有一项功能 - 如果未安装该应用,您可以隐藏该共享:http://developer.android.com/reference/com/google/android/gms/plus/PlusShare.Builder.html#isGooglePlusAvailable()

如果您只是在进行基本分享,那么如果用户未安装Google+,则该功能将通过Google Play服务运行:

PlusShare.Builder share = new PlusShare.Builder(this);
share.setText("hello everyone!");
share.setContentUrl(Uri.parse("http://stackoverflow.com"));
share.setType("text/plain");
startActivityForResult(share.getIntent(), REQ_START_SHARE);

所以只要你应该使用PlusShare,你应该没问题。

(编辑,因为我忘了这个!)