1

enter image description hereI'm working with kivymd and using an MDFloatingActionButtonSpeedDial cannot figure out how to use it to share the content of the app with a link to download the like we share youtube video on WhatsApp, just like above

Here's my code

    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')
Vinz
  • 255
  • 1
  • 9

1 Answers1

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)
Xyanight
  • 1,315
  • 1
  • 7
  • 10