How to share image in google Plus through an android app?

前端 未结 6 1741
既然无缘
既然无缘 2020-12-24 07:54

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;
pho         


        
6条回答
  •  离开以前
    2020-12-24 08:31

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

提交回复
热议问题