【问题标题】:How to use share button to share content of my app如何使用分享按钮分享我的应用程序的内容
【发布时间】:2020-11-29 00:57:02
【问题描述】:

我正在使用 kivymd 并使用 MDFloatingActionButtonSpeedDial 无法弄清楚如何使用它来共享应用程序的内容,并提供下载链接,就像我们在 WhatsApp 上共享 youtube 视频一样,就像上面一样

这是我的代码

    data = {
        "facebook": "Facebook",
        "whatsapp": "WhatsApp",
        "instagram": "Instagram",
        "twitter": "Twitter",
    }

    def callback(self, instance):
        print('Hello')
        print(instance.icon)
        if instance.icon == "facebook":
            print('Share it on Facebook')
        elif instance.icon == 'whatsapp':
            print('Share it on WhatsApp')
        elif instance.icon == 'twitter':
            print('Share it on Twitter')
        else:
            print('Share it on Instagram')

【问题讨论】:

    标签: kivy python-3.7 kivy-language share-button kivymd


    【解决方案1】:
    # Native method for Android.
    def share(title, text):
        from kivy import platform
    
        if platform == 'android':
            from jnius import autoclass
    
            PythonActivity = autoclass('org.kivy.android.PythonActivity')
            Intent = autoclass('android.content.Intent')
            String = autoclass('java.lang.String')
            intent = Intent()
            intent.setAction(Intent.ACTION_SEND)
            intent.putExtra(Intent.EXTRA_TEXT, String('{}'.format(text)))
            intent.setType('text/plain')
            chooser = Intent.createChooser(intent, String(title))
            PythonActivity.mActivity.startActivity(chooser)
    

    【讨论】:

      猜你喜欢
      • 2013-03-11
      • 2014-04-23
      • 1970-01-01
      • 1970-01-01
      • 2016-05-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多