Reputation: 1636
I am developing app for Instagram analytics and I want to have funcionality to share photos or videos from mobile phone. Is there any API for posting pictures and videos?
If there is not, I know there is intent for sharing, but how to handle if the user has multiple accounts on his phone? Is there a chooser for the account or how is it done?
Im developing it mainly for Android, so, it would be good to know how to do this from android.
Upvotes: 1
Views: 979
Reputation: 69681
not possible to post image in Instagram like facebook or twitter.
use below code to share with intent
btnShareIMG.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Intent intent = getPackageManager().getLaunchIntentForPackage("com.instagram.android");
if (intent != null)
{
Intent shareIntent = new Intent();
shareIntent.setAction(Intent.ACTION_SEND);
shareIntent.setPackage("com.instagram.android");
try {
shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(MediaStore.Images.Media.insertImage(getContentResolver(), imagePath, "Nilesh", "Rathod")));
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
Log.e("ERROR",e.printStackTrace());
}
shareIntent.setType("image/jpeg");
startActivity(shareIntent);
}
else
{
intent = new Intent(Intent.ACTION_VIEW);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
intent.setData(Uri.parse("market://details?id="+"com.instagram.android"));
startActivity(intent);
}
}
});
Upvotes: 2