I've found this answer, which explains how to create a different intent for each app, but some why it does not work:
here is the code that reproduces the issue, you can even comment the if
and you will stick get the text
and not the twitter
public Intent getShareChooserIntent(Context context) {
Intent basicIntent = new Intent();
basicIntent.setAction(Intent.ACTION_SEND);
basicIntent.setType("text/plain");
basicIntent.putExtra(Intent.EXTRA_TEXT, "text");
basicIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
PackageManager pm = context.getPackageManager();
Intent openInChooser = Intent.createChooser(basicIntent, "share");
List<ResolveInfo> resInfo = pm.queryIntentActivities(basicIntent, 0);
List<LabeledIntent> intentList = new ArrayList<LabeledIntent>();
for (int i = 0; i < resInfo.size(); i++) {
ResolveInfo ri = resInfo.get(i);
String packageName = ri.activityInfo.packageName;
Intent realIntent = new Intent();
realIntent.setAction(Intent.ACTION_SEND);
realIntent.setType("text/plain");
realIntent.putExtra(Intent.EXTRA_TEXT, "text");
realIntent.putExtra(Intent.EXTRA_SUBJECT, "subject");
if (packageName.contains("twitter")) // !!!!THIS LINE!!!!
realIntent.putExtra(Intent.EXTRA_TEXT, "twitter");
intentList.add(new LabeledIntent(realIntent, packageName, ri.loadLabel(pm), ri.icon));
}
openInChooser.putExtra(Intent.EXTRA_INITIAL_INTENTS, intentList.toArray( new LabeledIntent[ intentList.size()]));
return openInChooser;
}
what am I doing wrong?