3 ms·
In practical terms, you can only use frameworks like Kivy [1] to do UI on Android. But the result is completely non-native as Kivy renders its components on top
by jventura 10y ago
In practical terms, you can only use frameworks like Kivy [1] to do UI on Android. But the result is completely non-native as Kivy renders its components on top of an openGL window.
If you want to use Python and native UI components at the same time, you must run Python as a kind-of backend layer, where you call JNI functions from Java which will be redirected to the Python interpreter through C/C++. I have done this with an app that I have on the Play Store [2] which shares all non-UI code with a web app [3]. Even the charts are similar as they are generated as SVGs on my Python code.
This architecture allows me to have native frontends on different platforms, and I have open-sourced PyBridge [4] to be used as starting point for everyone who wants to use something like this: basically, you send JSON messages from Java to Python with the name of a function and the arguments, and you get the response.
[1] https://kivy.org/ https://kivy.org/
[2] https://play.google.com/store/apps/details?id=com.flatangle.charts https://play.google.com/store/apps/details?id=com.flatangle....
[3] http://elements.flatangle.com/ http://elements.flatangle.com/
[4] https://github.com/joaoventura/pybridge https://github.com/joaoventura/pybridge