Flickr, Tumblr, Instagram share intent in Android

2019-07-17 10:31发布

I want to share image via Flickr, Tumblr, Instagram. I want to do this with these 3 installed apps. I found for Instagram:

Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("image/*");
shareIntent.putExtra(Intent.EXTRA_TEXT, "" + getShareText());
shareIntent.putExtra(Intent.EXTRA_SUBJECT, "" + getShareText());
shareIntent.putExtra(Intent.EXTRA_STREAM,
                    Uri.parse("file://" + file.getAbsolutePath()));
shareIntent.setPackage("com.instagram.android");

Can I have Tumblr and Flickr also? Yes, I can do with Oauth process by integrating libs. But I want to share via particular installed app.

3条回答
地球回转人心会变
2楼-- · 2019-07-17 11:21

If you remove the last line (setPackage) all installed apps that can handle sending images will show up in the app chooser dialog, including tumblr and flickr. In case you want to limit the apps to only the three apps you mention: why would you? You'd just be limiting what a user can do with your app. I don't think that's possible anyway.

查看更多
来,给爷笑一个
3楼-- · 2019-07-17 11:21

More detailed information on creating Android intents for images and videos is available at http://instagram.com/developer/mobile-sharing/android-intents/

查看更多
贪生不怕死
4楼-- · 2019-07-17 11:34

Just set the correct package name in :

sendIntent.setPackage(PACKAGE_NAME);
  • Tumblr : com.tumblr
  • Flickr : com.yahoo.mobile.client.android.flickr

You can find the package names in the Google Play Store URLs :

https://play.google.com/store/apps/details?id=PACKAGE_NAME

PS : it is better to check if the app is installed on the device first :

  try
  {
    getPackageManager().getApplicationInfo(PACKAGE_NAME, 0);
  }
  catch (PackageManager.NameNotFoundException e)
  {
    // Twitter not installed
  }

Sharing using SEND_ACTION do not require OAUTH in your app, auth is managed in the targeted app.

Thanks

查看更多
登录 后发表回答