简体   繁体   English

在Android应用中将图片分享到Google+?

[英]Share image to Google+ in Android app?

I'm working on a project that needs share image from my app to Google+. 我正在开发一个项目,需要从我的应用程序分享图像到Google+。 But when find out some samples relating to my problems, they requires installed Google+ from Google Play for sharing anything. 但是,当找到与我的问题相关的一些示例时,他们需要从Google Play安装Google+才能分享任何内容。 So the question is : How can I share from my app without installing any extra app? 所以问题是:如何在不安装任何额外应用程序的情况下从我的应用程序共享? Or install Google+ from Google Play is the only way to solve my problem? 或者从Google Play安装Google+是解决我问题的唯一方法吗?

Thank you for your attention! 感谢您的关注!

Hope May this help you... 希望这可以帮助你......

File tmpFile = new File("/path/to/image");
 final String photoUri = MediaStore.Images.Media.insertImage(
         getContentResolver(), tmpFile.getAbsolutePath(), null, null);

 Intent shareIntent = ShareCompat.IntentBuilder.from(this)
         .setText("Hello from Google+!")
         .setType("image/jpeg")
         .setStream(Uri.parse(photoUri))
         .getIntent()
         .setPackage("com.google.android.apps.plus");

The Google+ app only supports content:// URIs. Google+应用仅支持内容:// URI。 You will need to use the MediaStore API for this... 您将需要使用MediaStore API ...

I guess you can always take a look at the web api if they provide you with means to authenticate your user and upload posts with an image. 我想你总是可以看一下web api,如果它们为你提供了验证用户身份和上传帖子的方法。

I assume however, that simply using the app itself will save you a lot of hassle. 然而,我认为,简单地使用应用程序本身将为您节省很多麻烦。

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

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