I want to create one application which share image on twitter.
But when i click on button it show message “no application perform this action”.
is there any wrong in following code?
private void share()
{
// TODO Auto-generated method stub
Intent tweetIntent = new Intent(Intent.ACTION_SEND);
tweetIntent.setType("application/twitter");
tweetIntent.putExtra(android.content.Intent.EXTRA_TEXT, "Test; please ignore");
startActivity(Intent.createChooser(tweetIntent, "Choose one"));
}
The Twitter application needs to be installed and probably the user needs to be actively logged in (most people are) for this to work. I don’t think the
tweetIntent.setType("application/twitter");works, I’ve never seen that. You can limit the share against Twitter by filtering by it’s application package name,tweetIntent.setPackage("com.twitter.android");. You’ll want to verify that this is available to you by using the PackageManager. Here’s the possible code below, I didn’t test this.Android’s share intent is meant for sending data for sharing to other applications. It’s possible that you can limit the share to a specific application like you are doing. But, you’re going against the grain of how Android works and you open yourself up to incompatibility issues by doing it. You might be better off using the Twitter API directly.
The rationale is that if the user doesn’t have Twitter installed then chances are they don’t really care about it. But they might want to share the content on another service like Facebook.