Unable to cast Action Provider to Share Action Provider

后端 未结 8 1068
一个人的身影
一个人的身影 2020-11-29 19:58

Below is the code for my Activity

    import android.app.Activity;
    import android.os.Bundle;
    import android.support.v7.widget.ShareActionProvider;
          


        
8条回答
  •  情歌与酒
    2020-11-29 20:16

    None of the solutions here solved my problem with ShareActionProvider, not casting / returning null. I ended up replacing ShareActionProvider with just an Intent.SEND_ACTION to share images in my app, like presented in Android Developers tutorial: https://developer.android.com/training/sharing/send

    Although Google mentions in this tutorial that: Note: The best way to add a share action item to an ActionBar is to use ShareActionProvider, which became available in API level 14. ShareActionProvider is discussed in the lesson about Adding an Easy Share Action. I found much simpler to implement just the Intention.SEND_ACTION. Not sure if there are other reasons to implement the ShareActionProvider...

提交回复
热议问题