如何通过Android应用程序共享图像在谷歌加? [英] How to share image in google Plus through an android app?

查看:119
本文介绍了如何通过Android应用程序共享图像在谷歌加?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经试过这种code,但我没有看到照片中我的帐户的共享。

 档案文件=新的文件(SD卡/ 1346249742258.jpg);
字符串photoUri = NULL;
photoUri = file.getAbsolutePath();

意图shareIntent = ShareCompat.IntentBuilder.from(本)
        .setText(在谷歌共享的图像!)。的setType(为image / jpeg)
        .setStream(Uri.parse(photoUri))。getIntent()
        .setPackage(com.google.android.apps.plus);
startActivity(shareIntent);
 

解决方案

Google+应用仅支持内容: // URI的的。您将需要使用 MediaStore API用于这一目的。

 文件TMPFILE =新的文件(/路径/要/图像);
 最后弦乐photoUri = MediaStore.Images.Media.insertImage(
         getContentResolver(),tmpFile.getAbsolutePath(),NULL,NULL);

 意图shareIntent = ShareCompat.IntentBuilder.from(本)
         .setText(你好来自Google+的!)
         .setType(为image / jpeg)
         .setStream(Uri.parse(photoUri))
         .getIntent()
         .setPackage(com.google.android.apps.plus);
 

I have already tried this code, but i didn't saw photo shared in my account.

File file = new File("sdcard/1346249742258.jpg");
String photoUri = null;
photoUri = file.getAbsolutePath();

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

解决方案

The Google+ app only supports content:// URIs. You will need to use the MediaStore API for this purpose.

 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");

这篇关于如何通过Android应用程序共享图像在谷歌加?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆