Kivy and Bluetooth device discovery

I saw here ( ) how to use pyjnius to access java classes using kivy to connect via bluetooth. What I am trying to do is open new devices and connect to them insecurely using sdp. I'm not sure how to get the results startDiscovery()

in kivy. In java, you need to use a broadcast receiver. Should I use pyjnius to access the broadcast receiver from Android?


source to share

1 answer

You missed the BroadcastReceiver in the Python-for-android / module android.broadcast

:) It does exactly what you need, it is an implementation in Java / Pyjnius that allows you to get the result in Python.

Note that the actions to be listened to must be written in lowercase, without a prefix ACTION_


The layout for your application might look like this:

class TestApp(App):

    def build(self): = BroadcastReceiver(
            self.on_broadcast, actions=['found'])

    def on_broadcast(self, context, intent):
        # called when a device in found

    # Don't forget to stop and restart the receiver when the app is going
    # to pause / resume mode

    def on_pause(self):
        return True

    def on_resume(self):




All Articles