QSL4A - QPython’s Android script layer¶
SL4A is an acronym for Android’s script layer, QSL4A is QPython’s Android script layer.
What is SL4A?¶
The full name of SL4A Scripting Layer for Android, as the name suggests is Android’s script architecture layer, Its purpose is to develop Android applications using well-known scripting languages.Its working principle is based on RPC remote call, through the local script parser and the remote native Android server layer APK information exchange,That is to achieve a remote agent,The local script function calls is encapsulated by JSON format,pass to the Remote ECS APK and proceed to the actual android system function call,and the results of the operation will be fed back to the local script parser,finally the terminal will show the results of the operation.
QPython integrated support of SL4A, users can easily be invoked by Andrews characteristics Python code, by SL4A.
QSL4A supported interfaces¶
You need to turn on the QPython permission settings in your Android system settings to use the associated SL4A interface.
System application interface
Including clipboard, Intent object, broadcast, vibration, network status, version number, send mail, prompts, Input boxes, etc. (APIs Document)
Application: Mainly as an application management interface (APIs Document)
ActivityResult??In Android control ActivityResult the interface of behavior (APIs Document)
Common Intent??Access two-dimensional code, Use XX application to view the interface (APIs Document)
Android related device interface
Camera??Access & recall device’s camera interface (APIs Document)
Contact??Contact access interface (APIs Document)
Location??Access location interface (APIs Document)
Phone: Access the phone interface (APIs Document)
Media recording: able to control recording or video (APIs Document)
Sensor Management: Access Control & Sensor device (APIs Document)
Settings: Ability to set device screen, flight mode, ringtone mode, vibration mode, volume, brightness, etc. (APIs Document)
SMS: equipment can be access to SMS (APIs Document)
Speech recognition: Can recognize the user’s speech and returns the most likely outcome (APIs Document)
Tone Generator: The ability to generate DTMF speech from a given phone number (APIs Document)
Wake lock: The device’s wake lock interface (APIs Document)
WIFI: Device WIFI Management (APIs Document)
Battery Management: Provides the device’s battery management interface (APIs Document)
Media Player: Media Player Settings (APIs Document)
Preferences: Access / Control Preferences (APIs Document)
Text Voice: Control text to voice output (APIs Document)
Bluetooth: Control Bluetooth devices on your phone (APIs Document)
Signal strength: access phone signal strength information (APIs Document)
Webcam: A camera that controls the phone (APIs Document)
User interface: UI interface is used to control related exhibits, such as a text box, the password input box, the status bar, progress bar, date picker, etc. (APIs Document)
NFC: NFC related control, mainly provided in the NFC mode master/slave exchange information (APIs Document)
USB Host Sequence: A device used to control USB-like sequences from Android that has a USB host controller (APIs Document)
QPython relevant interface
QPy interface: Run QPython script on your phone (APIs Document)
Sample Code¶
In Android, you can import the androidhelper module to load QSL4A support.Let’s run a simple QSL4A script to experience the following:
import androidhelper
droid = androidhelper.Android()
line = droid.dialogGetInput()
s = "Hello, %s" % (line.result,)
droid.makeToast(line)