After looking around on StackOverflow a couple of times, I finally got the ability to share an image file working.
This is the code snippet that works - saveCard is a File that I have just saved and checked that it exists():
Intent share = new Intent( Intent.ACTION_SEND );
share.setType( "image/jpeg" );
share.putExtra( Intent.EXTRA_STREAM, Uri.fromFile( saveCard ) );
startActivity( Intent.createChooser( share, "Share Image" ) );
This, on the other hand, is my previous code that wasn't working:
Intent share = new Intent( Intent.ACTION_SEND );
share.setType( "image/jpeg" );
share.putExtra( Intent.EXTRA_STREAM, saveCard.toUri() );
startActivity( Intent.createChooser( share, "Share Image" ) );
For some reason, the toUri method on File doesn't work in this case. In any case, I'm glad I got it fixed :-)
No comments:
Post a Comment