简体   繁体   English

如何通过android中的移动应用通过Google+分享?

[英]how to share via Google+ from mobile app in android?

How to share via Google plus in android, Kindly send the code and details. 如何通过Google Plus在Android中共享,请发送代码和详细信息。

Intent gplus = ShareCompat.IntentBuilder.from(MainActivity.this)
        .setText("This site has lots of great information about  Android!http://www.android.com")
        .setType("text/plain")
        .getIntent()
        .setPackage("com.google.android.apps.plus");

 startActivity(gplus);

I tried to perform share via google plus in android using the above code..but my application gets crashed when i run this...kindly help me to execute.. 我试图使用上述代码通过Google Plus在Android中执行共享..但是运行此程序时我的应用程序崩溃了...请帮助我执行..

Try to run in mobile device. 尝试在移动设备上运行。 If you run your app in emulator, there is no google-play services library. 如果您在模拟器中运行应用,则没有Google Play服务库。 So run your app in real device. 因此,请在真实设备中运行您的应用。

Try the following code... 尝试以下代码...

// Launch the Google+ share dialog with attribution to your app. //启动归因于您应用的Google+共享对话框。

 Intent shareIntent = new PlusShare.Builder(MainActivity.this)
                      .setType("text/plain")
                      .setText("YOUR TEXT HERE")
                      .setContentUrl(Uri.parse("YOUR LINK HERE"))
                      .getIntent();

                  startActivityForResult(shareIntent, 0);

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM