noloman
noloman

Reputation: 11975

Android: different sharing depending on the app

I need to implemented a sharing for my app.

The thing is that the customer wants me to implement this in a way that if the user taps "Facebook", a certain text, image, url, description, etc will be shared, while for example if he taps on twitter, a certain string shorter than 140 chars will be written.

Is there a way to do this?

Thanks a lot in advance!

EDIT: I run into this post Android share intent chooser which says that there's no way to do this, unfortunately.

Upvotes: 0

Views: 284

Answers (1)

CommonsWare
CommonsWare

Reputation: 1006674

Is there a way to do this?

Not readily, mostly because from Android's standpoint, there is no Facebook, and there is no Twitter.

Facebook and Twitter are Web sites. They also have APIs/SDKs, leading to Android apps. The key is that there are apps, plural. Twitter themselves has more than one app that they have published, let alone third-party clients.

You have no way of knowing whether or not there are any apps for Web site XYZ installed. Some complete idiots will say "oh, just check for this-and-so package name". Even if this-and-so package name exists, there is no evidence that the user uses it -- it might be preinstalled and unable to be removed, so it lingers. And, there is no guarantee that the official app will keep this-and-so package name forever, or will support sharing content via ACTION_SEND the same ways forever, etc.

You are certainly welcome to have your app share multiple types of things. However, the user will need to choose the type of thing first, then choose any app that supports that type. If the user wants to use "a certain string shorter than 140 chars" with Facebook, or Gmail, or Evernote, instead of Twitter, that is their choice. You could roll your own chooser, that presents the ACTION_SEND apps and then have the user choose what to send, but since you have no idea if what they chose happens to be a Twitter client or not, you cannot reliably tailor the content to the underlying Web site.

Upvotes: 3

Related Questions