I'm using ABS the ShareActionProvider. I have followed this code : https://github.com/JakeWharton/ActionBarSherlock/blob/master/samples/demos/src/com/actionbarsherlock/sample/demos/ShareActionProviders.java and its working with the latest version of Android (4.0+) but not with Android 2.x, I can't click on the icon.
Here is my code :
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.share, menu);
MenuItem actionItem = menu.findItem(R.id.menu_item_share_action_provider_action_bar);
actionProvider = (ShareActionProvider) actionItem.getActionProvider();
actionProvider.setShareHistoryFileName(null);
actionProvider.setShareIntent(share("More apps : https://play.google.com/store/apps/developer?id=Stéphane+Mathis"));
if(mItem != null)
{
actionProvider.setShareIntent(share(mItem.content));
}
super.onCreateOptionsMenu(menu, inflater);
}
private Intent share(String message)
{
final Intent MessIntent = new Intent(Intent.ACTION_SEND);
MessIntent.setType("text/plain");
MessIntent.putExtra(Intent.EXTRA_TEXT, message);
return MessIntent;
}
Did I miss something ?
EDIT : I tried the "official" demo from ABS and it's not working in the emulator, but it works on a real device. It's the same thing with my code, working with a real device ( tested with 4.1.2, 4.2.1 and 2.3.3) but not in the emulator. So what do I do ? I feel unconfortable to publish an app that doesn't work when I test it in the emulator.
I think this is due to a bug described here, in short emulator does not have more than 1 app installed that is able to get this share intent.