I use intent and Action.SEND for sharing my custom message on social networks like WhatsApp , twitter, Facebook and GMail. Everything is ok on Gmail and other applications e
What I did was actually to intercept the chosen target of the intenthandlers, you can do that by using your actionprovider. Let's say you created an item that with an onclick starts the intent. In order to do that, you can instantiate an actionprovider to do so. This actionprovider can have a setOnShareTargetSelectedListener to intercept any intents that you want to handle differently (or not at all ^^). See the code below for how to configure your actionprovider.
actionProvider.setShareIntent(createShareIntent());
actionProvider.setOnShareTargetSelectedListener(new OnShareTargetSelectedListener(){
@Override
public boolean onShareTargetSelected(ShareActionProvider source,
Intent intent) {
if ("com.facebook.katana".equals(intent.getComponent().getPackageName()) && mfacebooksharer != null) {
mfacebooksharer.shareStatus(subject, text);
return true;
}
return false;
}
});
Whenever facebook is chosen, I use my mfacebooksharer to handle the intent and follow the facebook API. Ofcourse, that actionrpovider needs to have an intent. (Just like you wanted to work with an intent). I use the method below to create the intent.
private Intent createShareIntent() {
intentsetter.setIntentleave(true);
Intent shareIntent = new Intent(Intent.ACTION_SEND);
shareIntent.setType("text/plain");
shareIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, subject);
shareIntent.putExtra(android.content.Intent.EXTRA_TEXT, text);
return shareIntent;
}