问题
I have developed a actionbar share button, however when I run the app the button does work but it crashes the application when I try to share the images with other apps. For example if I share the image with Twitter or message the application just crashes and says that "Twitter or Message has crashed.
回答1:
EXTRA_STREAM is supposed to hold a content: Uri.
In practice, you can often use a file: Uri pointing to a file on external storage, though that will be a problem more and more as time goes along.
You are trying to use android.resource:. Few apps support android.resource: Uri values in general, let alone for EXTRA_STREAM.
Your choices are:
Write the resources out to files, then use
FileProvideror perhapsfile:UrivaluesUse my StreamProvider to serve your resources via
content:UrivaluesDo not attempt to share resources
Beyond that, also note that your android.resource Uri seems rather mangled, as you seem to have a newline character and the literal string "getPackageName()" as part of the value.
来源:https://stackoverflow.com/questions/35877234/android-button-crashes