Flickr, Tumblr, Instagram share intent in Android

耗尽温柔 提交于 2019-12-11 01:25:41

问题


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.


回答1:


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




回答2:


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:


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



来源:https://stackoverflow.com/questions/16644074/flickr-tumblr-instagram-share-intent-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!