I'm trying to share a simple text using ShareActionProvider with android.support.v7 to put a Share-button in the ActionBar. My App must work with minimal API Level 8. The Problem: When I emulate the code with API 19 (targel level) it works fine, but when I emulate with an API-8 device, the pop-up menu with the list of apps to share shows only the name of the apps, without its icons. I tried with a real android device with API-9 and got the same problem: no icons too. Here are my codes:
in menu.xls:
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
tools:context="package.ActivityName" >
<item
android:id="@+id/menuitemShare"
android:orderInCategory="1"
android:title="@string/menu1"
android:icon="@drawable/ic_action_share"
app:showAsAction="ifRoom"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
/>
</menu>
in java activity:
public class ActivityName extends ActionBarActivity {
private ShareActionProvider mShareActionProvider;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
getMenuInflater().inflate(R.menu.bem_vindo2, menu);
MenuItem shareItem = menu.findItem(R.id.menuitemCompartilhar);
mShareActionProvider = (ShareActionProvider)
MenuItemCompat.getActionProvider(shareItem);
mShareActionProvider.setShareIntent(getDefaultIntent());
return super.onCreateOptionsMenu(menu);
}
private Intent getDefaultIntent() {
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, "text to share");
return intent;
}
}