Android button crashes

我的未来我决定 提交于 2019-12-11 23:15:44

问题


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:

  1. Write the resources out to files, then use FileProvider or perhaps file: Uri values

  2. Use my StreamProvider to serve your resources via content: Uri values

  3. Do 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

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