How to use share button to share content of my app

1.2k Views Asked by At

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')
1

There are 1 best solutions below

0
Xyanight On
# 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)