share a photo in instagram
Asked Answered
P

1

1

i'm developping an app and i'm trying to share a picture in Instagram .

i'm using the code below :

Intent i = new Intent(Intent.ACTION_SEND);
i.setType("image/jpeg");
i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file:///"+savedPhotoPath));//savedPhotoPath is the path of my picture stored somewhere in the sdcard
startActivity(Intent.createChooser(i, "Share Image"));

the problem is that the instagramm is launched with the home activity,( i want to have the activity of share that picture to be launched ).

i've tried to put the extras like this :

i.putExtra(Intent.EXTRA_STREAM, new File(savedPhotoPath));

and

i.putExtra(Intent.EXTRA_STREAM, Uri.parse(savedPhotoPath));

with the same result , always , the home activity of instagram application is launched .

any ideas how to solve this problem?

Regards,

Pyroelectricity answered 21/11, 2012 at 16:21 Comment(3)
#11298430Misdate
thanks @Misdate , i've just founded that post and i've figured it out , it's just a simple error of adding a slash in the path :)Pyroelectricity
Are you also able to send your app name along with your image So that other can Recognize that this content is send via a different app Not Instagram directlyCorking
P
2

it's just a stupid error i've made, i've added a slash on the file:/// path , and it will concat with savedPhotoPath and it will become 4 slashes , so the correct way to put extras is :

i.putExtra(Intent.EXTRA_STREAM, Uri.parse("file://"+savedPhotoPath));// it will give : file:///sdcard/...
Pyroelectricity answered 21/11, 2012 at 16:42 Comment(1)
Are you also able to send your app name along with your image So that other can Recognize that this content is send via a different app Not Instagram directlyCorking

© 2022 - 2024 — McMap. All rights reserved.