0

I'm using UIL to display images in a gridview. When one is selected it displays in a fullscreen window (UIL's ImagePagerActivity class) This screen allows you to flip through the available pictures. I want to use the ShareActionProvider in the action bar to share the currently displayed picture. I keep getting a null pointer exception when loading the onCreateOptionsMenu where it sets the shareIntent. I think it's not finding the displayed picture. Can someone look over this and help?

XML

    <?xml version="1.0" encoding="utf-8"?>
    <menu xmlns:android="http://schemas.android.com/apk/res/android" >

    <item
        android:id="@+id/menu_item_share"
        android:actionProviderClass="android.suport.v7.widget.ShareActionProvider"
        android:showAsAction="ifRoom"
        android:title="Share"/>
    </menu>

Android

     public boolean onCreateOptionsMenu(Menu menu) {

        getMenuInflater().inflate(R.menu.album_menu, menu);
        MenuItem item = menu.findItem(R.id.menu_item_share);
        mShareActionProvider = (ShareActionProvider) item.getActionProvider();

        mShareActionProvider.setShareIntent(getDefaultIntent());

    return true;
    }


    private Intent getDefaultIntent() {

        Bitmap cachedImage = imageLoader.getMemoryCache().get(imageUrls[pagerPosition]);

        Intent intent = new Intent(Intent.ACTION_SEND);
        intent.setType("image/*");
        intent.putExtra(Intent.EXTRA_STREAM, cachedImage);
        return intent;


}   
JeffK
  • 247
  • 1
  • 5
  • 18
  • Which object is null? `imageLoader`? `getMemoryCache()`? `imageUrls`? Might help to decompose that line and find out where the problem is. – ianhanniballake Oct 29 '13 at 23:22
  • Okay, I just changed the xml from android:actionProviderClass="android.suport.v7.widget.ShareActionProvider" to android:actionProviderClass="android.widget.ShareActionProvider" and that allows the page to load and me to select the share icon. Any item I choose (email, sms, facebook) they either crash or don't have the picture attached. – JeffK Oct 29 '13 at 23:41

0 Answers0