I am trying to click on the ShareActionProvider button on my mobile, but it is completely unresponsive. None of the sharing apps such as texting or emailing pop up. I've labeled the ShareActionProvider as menu_share in my xml file, and am using the method onOptionsItemSelected to respond to any clicks.
Java
import android.support.v7.widget.ShareActionProvider;
public class MainActivityFragment extends Fragment{
ArrayAdapter<String> mForecastAdapter;
//String[] parsedWeatherData;
ShareActionProvider provider;
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.forecastfragment, menu);
MenuItem item = menu.findItem(R.id.menu_share);
provider = (ShareActionProvider)
MenuItemCompat.getActionProvider(item);
}
public boolean onOptionsItemSelected(MenuItem item) {
switch (item.getItemId()) {
case R.id.menu_share:
Log.d("Weather", "Is menu share clicked");
doShare();
break;
default:
break;
}
return true;
}
public void doShare() {
String message = oneDayWeather;
// populate the share intent with data
Intent intent = new Intent(Intent.ACTION_SEND);
intent.setType("text/plain");
intent.putExtra(Intent.EXTRA_TEXT, message);
provider.setShareIntent(intent);
}
XML
<menu xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
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>
Any ideas?