I am creating an android app in which I have all ready added a share option to share content of the app, but I want to add another share option which will be able to share app download link (share this app), both the options use on create option menu, can anyone please tell me if it is possible to add two on create option or is there other way to add second share action. Following is the code I have used for "share this app" action.
private ShareActionProvider mShareActionProvider;
@Override
public boolean onCreateOptionsMenu(Menu menu) {
/** Inflating the current activity's menu with res/menu/items.xml */
getMenuInflater().inflate(R.menu.menu_main, menu);
/** Getting the actionprovider associated with the menu item whose id is share */
mShareActionProvider = (ShareActionProvider) menu.findItem(R.id.share).getActionProvider();
/** Setting a share intent */
mShareActionProvider.setShareIntent(getDefaultShareIntent());
return super.onCreateOptionsMenu(menu);
}
/** Returns a share intent */
private Intent getDefaultShareIntent(){
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_SUBJECT, "download the app");
intent.putExtra(Intent.EXTRA_TEXT," play.google.com ");
return intent;
}
menu_main
<item
android:title="Share"
android:id="@+id/menu_item_share"
android:showAsAction="ifRoom"
android:icon="@drawable/share"
/>
<item
android:id="@+id/share_this_app"
android:title="share this app"
android:showAsAction="never"
android:actionProviderClass="android.widget.ShareActionProvider"/>