views:

44

answers:

1

Using ACTION_SEND it's possible to post messages to various sharing services such as gmail, facebook, twitter, etc. Most services have reasonably long message lengths, but twitter in particular is very short (140 characters).

Not knowing in advance which service a user is going to select once the Intent.createChooser() dialog appears, is there a way to construct an intent that will result in a short message for twitter but a longer message for other services?

A: 

Probably you can try to Seperate Share with twitter as a option in your application. Get the text internally from your application in some edittext box validate and check whether its less than 140 characters and then send the text. Even in this case the users will be able to see all options when you call ACTION_SEND but they will be at least restricted to 140 characters.

Intent i=new Intent(android.content.Intent.ACTION_SEND);
i.setType("plain/text");
i.putExtra(Intent.EXTRA_SUBJECT, R.string.share_subject);
i.putExtra(Intent.EXTRA_TEXT, ...);
startActivity(Intent.createChooser(i, R.string.share_title));

You can also try using Bit ly API that can shorten URLs that are being posted on twitter

Rahul