stanna stanna - 1 month ago 19
Android Question

Remove most recent share app

How would i get rid of that little box that has the messaging app while retaining the share icon?

Share intent with most recent app

<item
android:id="@+id/share"
app:actionProviderClass="android.support.v7.widget.ShareActionProvider"
android:title="share"
app:showAsAction="always" />

Answer

If you don't want to show recent share app then remove ShareActionprovider. and add a icon to menu and handle share action like this

Intent sharingIntent = new Intent(android.content.Intent.ACTION_SEND); 
sharingIntent.setType("text/plain");
String shareBody = "Here is the share content body";
sharingIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "Subject Here");
sharingIntent.putExtra(android.content.Intent.EXTRA_TEXT, shareBody);
startActivity(Intent.createChooser(sharingIntent, "Share via"));