Mercurial > libervia-backend
comparison sat/plugins/plugin_misc_android.py @ 3654:3910ad643e9d
plugin android: use `callFromThread` instead of `callLater`:
`callLater` is not made to be called outside of main thread, `callFromThread` is the
method to call in this case.
author | Goffi <goffi@goffi.org> |
---|---|
date | Wed, 08 Sep 2021 11:17:13 +0200 |
parents | 7550ae9cfbac |
children | 524856bd7b19 |
comparison
equal
deleted
inserted
replaced
3653:d2b17f0f2615 | 3654:3910ad643e9d |
---|---|
307 | 307 |
308 # XXX: we need to keep a reference to BroadcastReceiver to avoid | 308 # XXX: we need to keep a reference to BroadcastReceiver to avoid |
309 # "XXX has no attribute 'invoke'" error (looks like the same issue as | 309 # "XXX has no attribute 'invoke'" error (looks like the same issue as |
310 # https://github.com/kivy/pyjnius/issues/59) | 310 # https://github.com/kivy/pyjnius/issues/59) |
311 self.br = BroadcastReceiver( | 311 self.br = BroadcastReceiver( |
312 callback=lambda *args, **kwargs: reactor.callLater(0, | 312 callback=lambda *args, **kwargs: reactor.callFromThread( |
313 self.onConnectivityChange), | 313 self.onConnectivityChange |
314 actions=["android.net.conn.CONNECTIVITY_CHANGE"]) | 314 ), |
315 actions=["android.net.conn.CONNECTIVITY_CHANGE"] | |
316 ) | |
315 self.br.start() | 317 self.br.start() |
316 | 318 |
317 @property | 319 @property |
318 def state(self): | 320 def state(self): |
319 return self._state | 321 return self._state |