java.lang.ClassNotFoundException: android.widget.shareActionProvider

95 views Asked by At

I am using Android Studio. In the menu.xml I have

<item android:id="@+id/action_share"
        android:title="@string/action_share"
        app:showAsAction="ifRoom"
        app:actionProviderClass="android.widget.shareActionProvider"
        />

In the code I am using

@Override
  public void onCreateOptionsMenu(Menu menu, MenuInflater inflater){
    inflater.inflate(R.menu.menu_detail,menu);
    MenuItem item = menu.findItem(R.id.action_share);
    mActionProvider = (ShareActionProvider) MenuItemCompat.getActionProvider(item);
  }
1

There are 1 answers

0
isma3l On BEST ANSWER

If your Activity extends AppCompatActivity, then you need to use android.support.v7.widget.ShareActionProvider

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