
from kivy.setupconfig import USE_SDL2def share(path): if platform == 'androID': from jnius import cast from jnius import autoclass if USE_SDL2: PythonActivity = autoclass('org.kivy.androID.PythonActivity') else: PythonActivity = autoclass('org.renpy.androID.PythonActivity') Intent = autoclass('androID.content.Intent') String = autoclass('java.lang.String') Uri = autoclass('androID.net.Uri') file = autoclass('java.io.file') shareIntent = Intent(Intent.ACTION_SEND) shareIntent.setType('"image/*"') imagefile = file(path) uri = Uri.fromfile(imagefile) shareIntent.putExtra(Intent.EXTRA_STREAM,uri) currentActivity = cast('androID.app.Activity',PythonActivity.mActivity) currentActivity.startActivity(shareIntent) 但它不起作用)它抛出此错误jnius.jnius.JavaException:u’androID / net / Uri’的无效实例在此行中传递给u’java / lang / String’shareIntent.putExtra(Intent.EXTRA_STREAM,URI).我怎样才能解决这个问题?
解决方法 我找到了解决方案您必须将uri转换为parcelable,然后将其传递给intent:parcelable = cast('androID.os.Parcelable',uri)shareIntent.putExtra(Intent.EXTRA_STREAM,parcelable) 总结 以上是内存溢出为你收集整理的kivy android分享图片全部内容,希望文章能够帮你解决kivy android分享图片所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)