ShareActionProvider is null

会有一股神秘感。 提交于 2019-12-03 04:07:20

You could just create a ShareActionProvider and assign it.

mShareActionProvider = new ShareActionProvider();
mShareActionProvider.setShareIntent(createShareIntent())
MenuItemCompat.setActionProvider(item, mShareActionProvider);
radistao

You have wrong namespace usage in XML:

<menu xmlns:android="http://schemas.android.com/apk/res/android"             xmlns:app="http://schemas.android.com/apk/res-auto">

  <item android:actionProviderClass="android.support.v7.widget.ShareActionProvider"

should be app:actionProviderClass (the provider class is from apk resources, not native android classes).

See https://stackoverflow.com/a/32602896/907576

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!