Share image and text through whatsapp

Whatsapp Support Image sharing along with text. Intent shareIntent = new Intent(); shareIntent.setAction(Intent.ACTION_SEND); shareIntent.putExtra(Intent.EXTRA_TEXT,title + “\n\nLink : ” + link ); shareIntent.putExtra(Intent.EXTRA_STREAM, Uri.parse(imageFilePath)); shareIntent.setType(“image/*”); startActivity(Intent.createChooser(shareIntent, “Share image via:”)); This will share image and EXTRA_TEXT will consider as image caption.

How do you turn off share history when using ShareActionProvider?

For me, the best solution for avoid the history icon is don’t use ShareActionProvider, instead of it, create it as any other action: <item android:id=”@+id/menu_action_share” android:showAsAction=”ifRoom” android:icon=”@drawable/ic_action_share” android:title=”@string/share”/> at the menu/activity_actions.xml put a item with the ic_action_share icon… @Override public boolean onCreateOptionsMenu(Menu menu) { getMenuInflater().inflate(R.menu.activity_actions, menu); return super.onCreateOptionsMenu(menu); } Inflate the menu normally… private void … Read more

How to hide the share action (which use most) icon near the share action provider?

If you wish to keep all the share history data model, but just don’t want the extra “default share activity” icom. The answer at How do you turn off share history when using ShareActionProvider? is not good enough. What you should do is: Copy these classes from the ActionBarSherlock to your project code ShareActionProvider.java ActivityChooserView.java … Read more

Unable to cast Action Provider to Share Action Provider

I had the same problem and I have found the solution: 1) You have to use: <menu xmlns:android=”http://schemas.android.com/apk/res/android” xmlns:bwq=”http://schemas.android.com/apk/res-auto” > <item android:id=”@+id/menu_share” android:title=”@string/menu_share” bwq:actionProviderClass=”android.support.v7.widget.ShareActionProvider” bwq:showAsAction=”always”/> </menu> 2) and in Java import android.support.v7.widget.ShareActionProvider; and // Locate MenuItem with ShareActionProvider MenuItem item = menu.findItem(R.id.menu_share); // Fetch and store ShareActionProvider mShareActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);