Null Pointer exception in using support library share action provider

蹲街弑〆低调 提交于 2019-11-30 17:38:05
Anuranjit Maindola

I found the error. The problem was that support library requires to have a custom prefix and not android:actionProviderClass . What i was doing wrong that i used android:actionProviderClass instead of customprefix:actionProviderClass

See here: https://developer.android.com/training/basics/actionbar/adding-buttons.html

ssantos

If this line

shareAction.setShareIntent(shareIntent);

is throwing a NullPointerException, this sentence

(ShareActionProvider) MenuItemCompat.getActionProvider(item);

must be returning null.

Have a look at the post below, which talks about reasons why this would happen.

NullPointerException on setShareIntent using ActionBarSherlock

I changed this

android:actionProviderClass=widget.ShareActionProvider" />

To this

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