<bdo id='pAfAl'></bdo><ul id='pAfAl'></ul>

<small id='pAfAl'></small><noframes id='pAfAl'>

  • <tfoot id='pAfAl'></tfoot>
  • <i id='pAfAl'><tr id='pAfAl'><dt id='pAfAl'><q id='pAfAl'><span id='pAfAl'><b id='pAfAl'><form id='pAfAl'><ins id='pAfAl'></ins><ul id='pAfAl'></ul><sub id='pAfAl'></sub></form><legend id='pAfAl'></legend><bdo id='pAfAl'><pre id='pAfAl'><center id='pAfAl'></center></pre></bdo></b><th id='pAfAl'></th></span></q></dt></tr></i><div id='pAfAl'><tfoot id='pAfAl'></tfoot><dl id='pAfAl'><fieldset id='pAfAl'></fieldset></dl></div>

      <legend id='pAfAl'><style id='pAfAl'><dir id='pAfAl'><q id='pAfAl'></q></dir></style></legend>

      1. kivy android 分享图片

        时间:2023-09-01
          • <tfoot id='D1G0N'></tfoot>
            <legend id='D1G0N'><style id='D1G0N'><dir id='D1G0N'><q id='D1G0N'></q></dir></style></legend>

            <small id='D1G0N'></small><noframes id='D1G0N'>

            • <bdo id='D1G0N'></bdo><ul id='D1G0N'></ul>
                    <tbody id='D1G0N'></tbody>
                1. <i id='D1G0N'><tr id='D1G0N'><dt id='D1G0N'><q id='D1G0N'><span id='D1G0N'><b id='D1G0N'><form id='D1G0N'><ins id='D1G0N'></ins><ul id='D1G0N'></ul><sub id='D1G0N'></sub></form><legend id='D1G0N'></legend><bdo id='D1G0N'><pre id='D1G0N'><center id='D1G0N'></center></pre></bdo></b><th id='D1G0N'></th></span></q></dt></tr></i><div id='D1G0N'><tfoot id='D1G0N'></tfoot><dl id='D1G0N'><fieldset id='D1G0N'></fieldset></dl></div>

                2. 本文介绍了kivy android 分享图片的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

                  问题描述

                  我想创建将使用 android ACTION_SEND 意图共享图像的共享按钮.这是我的代码:

                  I want to create share button that will use android ACTION_SEND intent for sharing image. It's my code:

                  from kivy.setupconfig import USE_SDL2
                  
                  
                  def 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: Invalid instance of u'android/net/Uri' passed for a u'java/lang/String' in这一行 shareIntent.putExtra(Intent.EXTRA_STREAM, uri).我该如何解决这个问题?

                  But it doesn't work) It throws this error jnius.jnius.JavaException: Invalid instance of u'android/net/Uri' passed for a u'java/lang/String' in this line shareIntent.putExtra(Intent.EXTRA_STREAM, uri). How can i fix this?

                  推荐答案

                  我找到了解决方案.您必须将 uri 转换为 parcelable,然后将其传递给意图:

                  I found solution. You must cast uri to parcelable and then pass it to intent:

                  parcelable = cast('android.os.Parcelable', uri)
                  shareIntent.putExtra(Intent.EXTRA_STREAM, parcelable)
                  

                  这篇关于kivy android 分享图片的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:移除或更换启动时的 kivy 闪屏 下一篇:Android使用buildozer编译错误

                  相关文章

                  最新文章

                3. <legend id='3zbF2'><style id='3zbF2'><dir id='3zbF2'><q id='3zbF2'></q></dir></style></legend>

                  <i id='3zbF2'><tr id='3zbF2'><dt id='3zbF2'><q id='3zbF2'><span id='3zbF2'><b id='3zbF2'><form id='3zbF2'><ins id='3zbF2'></ins><ul id='3zbF2'></ul><sub id='3zbF2'></sub></form><legend id='3zbF2'></legend><bdo id='3zbF2'><pre id='3zbF2'><center id='3zbF2'></center></pre></bdo></b><th id='3zbF2'></th></span></q></dt></tr></i><div id='3zbF2'><tfoot id='3zbF2'></tfoot><dl id='3zbF2'><fieldset id='3zbF2'></fieldset></dl></div>

                4. <small id='3zbF2'></small><noframes id='3zbF2'>

                      <bdo id='3zbF2'></bdo><ul id='3zbF2'></ul>
                  1. <tfoot id='3zbF2'></tfoot>