androidkivykivy-languagepyjniuskivymd

How to connect kivy app to Android's installed app


I have created a basic kivy app which provides certain links. Assume I have created a button. And now, when I press the button , it should show me my device's installed apps like WhatsApp,Facebook, Instagram and other apps to share this link.

Is this possible to do in kivy?if yes, then please do help me.


Solution

  • # 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)