Good day. I wrote a simple script in the Qpython3 application, which says that the charging is connected and that the battery is charged. Qpython uses the sl4a module ie:
import sl4a droid = sl4a.Android()
and further code ..
This all works great on the phone (Nexus5). I decided to make an application of this script independent of Qpython, etc.
Since there is a little experience building an application written in python and kivy is used as a kivy
, then the gui did, and inside the start button. I built the application using buildozer
, after installing python-android
. If you install this package on python 2.7.10
, then enter:
import android dir(android)
no Android class
If to install on python 3.4.3
, then at import the error generally falls out.
If you do the same in Qpython, you can see that the Android class is present.
I found sl4a.py on my phone and threw a folder on my computer in the same folder, I imported it, but when debugging you can see that there are some errors about socket (described in the Android class in the init section):
def __init__(self, addr=None): if addr is None: addr = HOST, PORT self.conn = socket.create_connection(addr) self.client = self.conn.makefile("rw") self.id = 0 if HANDSHAKE is not None: self._authenticate(HANDSHAKE)
In general, the question is: is it possible to somehow use this module to build your application ( apk
) or can sl4a be used only with Qpython?
I also tried to build the application as described here: https://github.com/kivy/python-for-android in this case, the installed application instead of 30 meters (when building buildozer) takes 100 meters! But also does not work.