- Android scripting environment ase
- Latest commit
- Git stats
- Files
- README.md
- About
- …code, cg, electronics, 3d printing…
- Installing the Android Scripting Environment on the Android Emulator
- #1: Install the Android SDK:
- #2: Create an Android Virtual Device (AVD):
- #3: Install the Android Scripting Environment (ASE):
- #4: Configure the ASE:
- In Conclusion…
- Index of reference pages:
- opensource.google.com
- Google Open Source Blog
- Introducing Android Scripting Environment
- Monday, June 8, 2009
- AndroidFacade¶
- Clipboard APIs¶
- Intent & startActivity APIs¶
- SendBroadcast APIs¶
- Vibrate¶
- NetworkStatus¶
- PackageVersion APIs¶
- System APIs¶
- SendEmail¶
- Toast, getInput, getPassword, notify APIs¶
- ApplicationManagerFacade¶
- Manager APIs¶
- CameraFacade¶
- CommonIntentsFacade¶
- Barcode¶
- View APIs¶
- ContactsFacade¶
- EventFacade¶
- LocationFacade¶
- Providers APIs¶
- Location APIs¶
- PhoneFacade¶
- PhoneStat APIs¶
- Call & Dia APIs¶
- Get information APIs¶
- MediaRecorderFacade¶
- Audio¶
- Video APIs¶
- SensorManagerFacade¶
- Start & Stop¶
- Read data APIs¶
- SettingsFacade¶
- Screen¶
- AirplanerMode¶
- Ringer Silent Mode¶
- Vibrate Mode¶
- Ringer & Media Volume¶
- Screen Brightness¶
- SmsFacade¶
- SpeechRecognitionFacade¶
- ToneGeneratorFacade¶
- WakeLockFacade¶
- WifiFacade¶
- BatteryManagerFacade¶
- ActivityResultFacade¶
- MediaPlayerFacade¶
- Control¶
- Get Information¶
- PreferencesFacade¶
- QPyInterfaceFacade¶
- TextToSpeechFacade¶
- EyesFreeFacade¶
- BluetoothFacade¶
- SignalStrengthFacade¶
- WebCamFacade¶
- UiFacade¶
- Dialog¶
- Progress¶
- Alert¶
- Dialog Control¶
- Layout¶
- WebView¶
- USB Host Serial Facade¶
- Requirements¶
- Status¶
- Author¶
Android scripting environment ase
SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.
Latest commit
Git stats
Files
Failed to load latest commit information.
README.md
#Scripting Layer for Android (SL4A)
SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface that makes it easy to get things done.
Scripts can be run interactively in a terminal and in the background. Python, Perl, JRuby, Lua, BeanShell, JavaScript, Tcl, and shell are currently supported, and we’re planning to add more. See the SL4A Video Help playlist on YouTube for various demonstrations of SL4A’s features.
SL4A is designed for developers and is alpha quality software.
- Even though a lot of contributors are working for Google, this is not an official Google product.
- SL4A is no longer under active development. However, some forks of this project may be.
The original Google Code wiki has been converted to Markdown and is available in the wiki branch. A few of the most important pages are:
Issues have been migrated from Google Code. However, this probject is no longer under active development. Consider responding to and filing new issues against an active fork.
Support for SL4A is provided by the community on the project mailing list.
About
SL4A brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device.
Источник
…code, cg, electronics, 3d printing…
Installing the Android Scripting Environment on the Android Emulator
Update : I have a newer post here describing how I got the SL4A installed on an actual phone. More work than I expected…
Based on my previous post, the thought of being able to run Python on an Android Device via the Android Scripting Environment seems… enticing. However, I personally do not own an Android Device, nor have plans to get one anytime soon (ah, love those AT&T contracts…). But there is the Android Emulator which I can run on my PC, why not use that in the meantime?
What I expected to be easy turned into quite a quest. But I got it working, and the steps are listed below. Specifically, this is a walkthrough on installing the Android SDK, creating an ‘Android Virtual Device’, launching the Android Emulator, installing the appropriate scripting language data on it, and running that language on the emulator. This was done on a WinXP system. I should also point out that this was my first foray into anything Android related, so I am quite a bit of a noob at this point. My knowledge does not stretch far beyond this tutorial
Finally, while my goal was to get Python running, you can use these steps to (presumably) get other languages (Lua, Perl, jRuby, BeanShell, Rhino) installed as well. My tutorial below will be based around Python and its associated dependencies, but you should be able to mentally replace that with the language of your choice.
#1: Install the Android SDK:
Based on this post, I got the SDK installed. I’d recommend you follow it as well. You can stop at their “Step6: Create a new Android Virtual Device”, since that’s what we’ll cover below. Note that this install process was done with version Android v2.0, can’t vouch for earlier versions.
- It ended up being installed here: C:\android-sdk-windows
- Not sure of the importance, but I read online that you need to add a Windows System Variable named ‘SDK_ROOT’ with the value of the tools dir in the SDK install location, which for me is ‘C:\android-sdk-windows\tools’
#2: Create an Android Virtual Device (AVD):
- I first created a shortcut on my desktop to this bat file which I use to launch the ‘Android SDK and AVD Manager’:
- C:\android-sdk-windows\tools\android.bat
- Under ‘Virtual Devices’, I created a new AVD, named it ‘ASE_test’. Specifics in the image:
- After creation, pick the AVD in the ‘List of existing Android Virtual Devices”, and “Start…”
- This will launch the Android Emulator:
- Getting closer…
#3: Install the Android Scripting Environment (ASE):
It’s important that the Android Emulator is open (& unlocked) and running while the below steps are performed.
I read a lot of documentation about making a disk image of a memory card that the AVD could load in place of a real one. I spent two hours trying to get this to work… it just didn’t happen. Then I learned that you can install the ASE via the ‘Android Debug Bridge’ (adb) in a shell, and everything got a lot easier…
- Download the ASE, and appropriate scripting language data. Find them at the ‘Android Scripting’ download page here:
- http://code.google.com/p/android-scripting/downloads/list
- These files specifically: (note: since the time of authoring this post, the below apk and zip files have been updated… be sure to grab the latest versions)
- http://android-scripting.googlecode.com/files/ase_r14.apk (The ASE itself)
- If you want to install Python, these are the files you’re after. If you’re using a different language, find similar files in the same download page. (Note: Based on blog reply below by Wolfgang, it explains this step may not be needed based on ASE updates. I have yet to test, so I’ll leave this info here for the time being)
- http://android-scripting.googlecode.com/files/python_r0.zip
- http://android-scripting.googlecode.com/files/python_scripts_r0.zip
- http://android-scripting.googlecode.com/files/python_extras_r0.zip
- After downloaded, for convenience, copy them to your SDK\tools dir:
- C:\android-sdk-windows\tools
- Install the ASE:
- Make sure the Android Emulator is up and running (& unlocked).
- In an OS shell, change directory to the SDK\tools directory.
- Execute these commands to install the ASE on the emulated Android Device (running in the background):
- Then, use these commands to copy the Python data to the virual sdcard on the emulator:
- That should do it! Your shell should look something like this when complete:
#4: Configure the ASE:
At this point, the ASE should be installed in the running Android Emulator, and the Python data (or whatever scripting language you’re using) copied to the virtual SD card.
- Expand the Application Tab. You should see the “ASE” icon. This means a successfull .apk install!
- Select the ASE icon. This will launch the Android Scripting Environment, and give you a screen saying “Start adding scripts and Interpreters by pressing the menu button”. We need to install the Python interpreter, so, press “MENU”.
- Along the bottom of the UI three buttons will pop up. Press the middle one “Interpreters”.
- This will clear the screen with only one option; “Shell”. Press the “MENU” button again.
- New buttons along the bottom, press “Add”
- AH, a big list of stuff to install! Scroll down to ‘Python 2.6.2’ and press it.
- This will start an extraction process, and you should see it extract the various Python .zip files you had put on the virtual SD card earlier.
- Now the UI has two options, “Shell” and “Python 2.6.2”. Press Python…
- This launches a Python shell. Success!
- Hitting the return button twice will take you to another menu that has all the default Python modules previously installed: notify_weather.py, saychat.py, etc. Press ‘test.py’:
- This will run that module, executing a variety of test suites on the emulated device.
- Pressing menu can take you into a module edit mode as well:
- That’s pretty cool… 😛
In Conclusion…
What to do now? First step, will be to go over all this info on the ‘Android Scripting Groups Wiki’: http://code.google.com/p/android-scripting/w/list
I have to say, interaction in the emulator itself is really slow, with lots of lag. I also had a weird issue where all the text I tried to type was being converted into Japanese. I had to go into my emulator’s Settings -> Language Keyboard -> And uncheck the first two options under “Text settings”. I don’t know what they are, since they’re in JAPANESE. But that fixed it.
Index of reference pages:
These are pages I pulled a lot of info from to figure all of this out:
Источник
opensource.google.com
Google Open Source Blog
The latest news from Google on open source releases, major projects, events, and student outreach programs.
Introducing Android Scripting Environment
Monday, June 8, 2009
The Android Scripting Environment (ASE) brings scripting languages to Android by allowing you to edit and execute scripts and interactive interpreters directly on the Android device. These scripts have access to many of the APIs available to full-fledged Android applications, but with a greatly simplified interface that makes it easy to:
- Handle intents
- Start activities
- Make phone calls
- Send text messages
- Scan bar codes
- Poll location and sensor data
- Use text-to-speech (TTS)
- And more
Scripts can be run interactively in a terminal, started as a long running service, or started via Locale. Python, Lua and BeanShell are currently supported, and we’re planning to add Ruby and JavaScript support, as well.
Scripts can be launched interactively or as background services.
You may ask, why write scripts instead of real Android applications? Admittedly, Android’s development environment makes life pretty easy, but you’re tied to a computer to do your work. ASE lets you develop on the device itself using high-level scripting languages to try out your idea now, in the situation where you need it, quickly. Have a look at the following example Lua script to see for yourself:
Here’s another useful script, this time in Python.
These scripts demonstrates several of the available APIs available for both Lua and Python. It is intended to be run as a service and silences the ringer when the phone is placed face down. For some scripting languages, like BeanShell, it’s possible to access Android’s Java API directly. To simplify things, ASE provides the AndroidFacade class. For other languages, like Python and Lua, the API is made available via JSON RPC calls to a proxy. Naturally this means that only the part of the API which has been wrapped by the AndroidFacade and AndroidProxy are available to cross-compiled interpreters like Python and Lua. Thankfully, both AndroidFacade and AndroidProxy are simple to extend.
If you’d like to give ASE a try, it’s not yet published to the Market, but will be soon. You can download the latest APK from our project page. Some sample scripts and documentation are also included there to help you get started. We always love to hear what you think, so please send us feedback or ask your questions in the ASE discussion group .
Источник
AndroidFacade¶
Clipboard APIs¶
Put text in the clipboard
Parameters: | text (str) – text |
---|
getClipboard ( text ) ¶
Read text from the clipboard
Returns: | The text in the clipboard |
---|
Intent & startActivity APIs¶
Starts an activity and returns the result
Parameters: |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
Parameters: |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
Parameters: | intent (Intent) – Intent in the format as returned from makeIntent |
---|---|
Returns: | A Map representation of the result Intent |
Starts an activity
Parameters: |
|
---|
Starts an activity
Parameters: |
|
---|
SendBroadcast APIs¶
Send a broadcast
Parameters: |
|
---|
Send a broadcast
Parameters: | intent (Intent) – Intent in the format as returned from makeIntent |
---|
Vibrate¶
Vibrates the phone or a specified duration in milliseconds
Parameters: | duration (int) – duration in milliseconds |
---|
NetworkStatus¶
Returns the status of network connection
PackageVersion APIs¶
Checks if version of QPython SL4A is greater than or equal to the specified version
Parameters: | requiredVersion (int) – requiredVersion |
---|---|
Returns: | true or false |
getPackageVersionCode ( packageName ) ¶
Returns package version code
Parameters: | packageName (str) – packageName |
---|---|
Returns: | Package version code |
getPackageVersion ( packageName ) ¶
Returns package version name
Parameters: | packageName (str) – packageName |
---|---|
Returns: | Package version name |
System APIs¶
Get list of constants (static final fields) for a class
Parameters: | classname (str) – classname |
---|---|
Returns: | list |
A map of various useful environment details
Returns: | environment map object includes id, display, offset, TZ, SDK, download, appcache, availblocks, blocksize, blockcount, sdcard |
---|
Writes message to logcat
Parameters: | message (str) – message |
---|
SendEmail¶
Launches an activity that sends an e-mail message to a given recipient
Parameters: |
|
---|
Toast, getInput, getPassword, notify APIs¶
Displays a short-duration Toast notification
Parameters: | message (str) – message |
---|
Queries the user for a text input
Parameters: |
|
---|
Queries the user for a password
Parameters: |
|
---|
Displays a notification that will be canceled when the user clicks on it
Parameters: |
|
---|
:: import androidhelper droid = androidhelper.Android() droid.notify(‘Hello’,’QPython’,’http://qpython.org’) # you could set the 3rd parameter None also
ApplicationManagerFacade¶
Manager APIs¶
Returns a list of all launchable application class names
Returns: | map object |
---|
Start activity with the given class name
Parameters: | classname (str) – classname |
---|
Returns a list of packages running activities or services
Returns: | List of packages running activities |
---|
Force stops a package
Parameters: | packageName (str) – packageName |
---|
CameraFacade¶
Take a picture and save it to the specified path
Returns: | A map of Booleans autoFocus and takePicture where True indicates success |
---|
cameraInteractiveCapturePicture ( targetPath ) ¶
Starts the image capture application to take a picture and saves it to the specified path
CommonIntentsFacade¶
Barcode¶
Starts the barcode scanner
Returns: | A Map representation of the result Intent |
---|
View APIs¶
Display content to be picked by URI (e.g. contacts)
Returns: | A map of result values |
---|
view ( uri, type, extras ) ¶
Start activity with view action by URI (i.e. browser, contacts, etc.)
Opens a map search for query (e.g. pizza, 123 My Street)
Opens the list of contacts
Opens the browser to display a local HTML file
Starts a search for the given query
ContactsFacade¶
Displays a list of contacts to pick from
Returns: | A map of result values |
---|
pickPhone ( ) ¶
Displays a list of phone numbers to pick from
Returns: | The selected phone number |
---|
contactsGetAttributes ( ) ¶
Returns a List of all possible attributes for contacts
Returns: | a List of contacts as Maps |
---|
contactsGetIds ( ) ¶
Returns a List of all contact IDs
Returns a List of all contacts
Returns contacts by ID
Returns the number of contacts
queryContent ( uri, attributes, selection, selectionArgs, order ) ¶
Content Resolver Query
Returns: | result of query as Maps |
---|
queryAttributes ( uri ) ¶
Content Resolver Query Attributes
Returns: | a list of available columns for a given content uri |
---|
EventFacade¶
Clears all events from the event buffer
eventRegisterForBroadcast ( category, enqueue ) ¶
Registers a listener for a new broadcast signal
Stop listening for a broadcast signal
Lists all the broadcast signals we are listening for
Returns and removes the oldest n events (i.e. location or sensor update, etc.) from the event buffer
Returns: | A List of Maps of event properties |
---|
eventWaitFor ( eventName, timeout ) ¶
Blocks until an event with the supplied name occurs. The returned event is not removed from the buffer
Returns: | Map of event properties |
---|
eventWait ( timeout ) ¶
Blocks until an event occurs. The returned event is removed from the buffer
Returns: | Map of event properties |
---|
eventPost ( name, data, enqueue ) ¶
Post an event to the event queue
Post an event to the event queue
Returns and removes the oldest event (i.e. location or sensor update, etc.) from the event buffer
Returns: | Map of event properties |
---|
waitForEvent ( eventName, timeout ) ¶
Blocks until an event with the supplied name occurs. The returned event is not removed from the buffer
Returns: | Map of event properties |
---|
startEventDispatcher ( port ) ¶
Opens up a socket where you can read for events posted
Stops the event server, you can’t read in the port anymore
LocationFacade¶
Providers APIs¶
Returns availables providers on the phone
Ask if provider is enabled
Location APIs¶
Starts collecting location data
Returns the current location as indicated by all available providers
Returns: | A map of location information by provider |
---|
stopLocating ( ) ¶
Stops collecting location data
Returns the last known location of the device
Returns: | A map of location information by provider |
---|
Returns a list of addresses for the given latitude and longitude
Returns: | A list of addresses |
---|
PhoneFacade¶
PhoneStat APIs¶
Starts tracking phone state
Returns the current phone state and incoming number
Returns: | A Map of “state” and “incomingNumber” |
---|
stopTrackingPhoneState ( ) ¶
Stops tracking phone state
Call & Dia APIs¶
Calls a contact/phone number by URI
Calls a phone number
Dials a contact/phone number by URI
Dials a phone number
Get information APIs¶
Returns the current cell location
Returns the numeric name (MCC+MNC) of current registered operator
Returns the alphabetic name of current registered operator
Returns a the radio technology (network type) currently in use on the device
Returns the device phone type
Returns the ISO country code equivalent for the SIM provider’s country code
Returns the MCC+MNC (mobile country code + mobile network code) of the provider of the SIM. 5 or 6 decimal digits
Returns the Service Provider Name (SPN)
Returns the serial number of the SIM, if applicable. Return null if it is unavailable
Returns the state of the device SIM card
Returns the unique subscriber ID, for example, the IMSI for a GSM phone. Return null if it is unavailable
Retrieves the alphabetic identifier associated with the voice mail number
Returns the voice mail number. Return null if it is unavailable
Returns true if the device is considered roaming on the current network, for GSM purposes
Returns the unique device ID, for example, the IMEI for GSM and the MEID for CDMA phones. Return null if device ID is not available
Returns the software version number for the device, for example, the IMEI/SV for GSM phones. Return null if the software version is not available
Returns the phone number string for line 1, for example, the MSISDN for a GSM phone. Return null if it is unavailable
Returns the neighboring cell information of the device
MediaRecorderFacade¶
Audio¶
Records audio from the microphone and saves it to the given location
Video APIs¶
Records video from the camera and saves it to the given location. Duration specifies the maximum duration of the recording session. If duration is 0 this method will return and the recording will only be stopped when recorderStop is called or when a scripts exits. Otherwise it will block for the time period equal to the duration argument. videoSize: 0=160×120, 1=320×240, 2=352×288, 3=640×480, 4=800×480.
recorderCaptureVideo ( targetPath, duration, recordAudio ) ¶
Records video (and optionally audio) from the camera and saves it to the given location. Duration specifies the maximum duration of the recording session. If duration is not provided this method will return immediately and the recording will only be stopped when recorderStop is called or when a scripts exits. Otherwise it will block for the time period equal to the duration argument.
Starts the video capture application to record a video and saves it to the specified path
Stops a previously started recording
SensorManagerFacade¶
Start & Stop¶
Starts recording sensor data to be available for polling
startSensingThreshold ( ensorNumber, threshold, axis ) ¶
Records to the Event Queue sensor data exceeding a chosen threshold
Starts recording sensor data to be available for polling
Stops collecting sensor data
Read data APIs¶
Returns the most recently recorded sensor data
Returns the most recently received accuracy value
Returns the most recently received light value
Returns the most recently received accelerometer values
Returns: | a List of Floats [(acceleration on the) X axis, Y axis, Z axis] |
---|
sensorsReadMagnetometer ( ) ¶
Returns the most recently received magnetic field values
Returns: | a List of Floats [(magnetic field value for) X axis, Y axis, Z axis] |
---|
sensorsReadOrientation ( ) ¶
Returns the most recently received orientation values
Returns: | a List of Doubles [azimuth, pitch, roll] |
---|
SettingsFacade¶
Screen¶
Sets the screen timeout to this number of seconds
Returns: | The original screen timeout |
---|
getScreenTimeout ( ) ¶
Gets the screen timeout
Returns: | the current screen timeout in seconds |
---|
AirplanerMode¶
Checks the airplane mode setting
Returns: | True if airplane mode is enabled |
---|
toggleAirplaneMode ( enabled ) ¶
Toggles airplane mode on and off
Returns: | True if airplane mode is enabled |
---|
Ringer Silent Mode¶
Checks the ringer silent mode setting
Returns: | True if ringer silent mode is enabled |
---|
toggleRingerSilentMode ( enabled ) ¶
Toggles ringer silent mode on and off
Returns: | True if ringer silent mode is enabled |
---|
Vibrate Mode¶
Toggles vibrate mode on and off. If ringer=true then set Ringer setting, else set Notification setting
Returns: | True if vibrate mode is enabled |
---|
getVibrateMode ( ringer ) ¶
Checks Vibration setting. If ringer=true then query Ringer setting, else query Notification setting
Returns: | True if vibrate mode is enabled |
---|
Ringer & Media Volume¶
Returns the maximum ringer volume
Returns the current ringer volume
Sets the ringer volume
Returns the maximum media volume
Returns the current media volume
Sets the media volume
Screen Brightness¶
Returns the screen backlight brightness
Returns: | the current screen brightness between 0 and 255 |
---|
setScreenBrightness ( value ) ¶
Sets the the screen backlight brightness
Returns: | the original screen brightness |
---|
checkScreenOn ( ) ¶
Checks if the screen is on or off (requires API level 7)
Returns: | True if the screen is currently on |
---|
SmsFacade¶
Parameters: |
|
---|
smsGetMessageCount ( unreadOnly, folder ) ¶
Returns the number of messages
Parameters: |
|
---|
smsGetMessageIds ( unreadOnly, folder ) ¶
Returns a List of all message IDs
Parameters: |
|
---|
smsGetMessages ( unreadOnly, folder, attributes ) ¶
Returns a List of all messages
Parameters: |
|
---|---|
Returns: |
smsGetMessageById ( id, attributes ) ¶
Returns message attributes
Parameters: |
|
---|---|
Returns: |
smsGetAttributes ( ) ¶
Returns a List of all possible message attributes
Deletes a message
Parameters: | id (int) – message ID |
---|---|
Returns: | True if the message was deleted |
smsMarkMessageRead ( ids, read ) ¶
Marks messages as read
Parameters: |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
Parameters: |
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
Parameters: |
|
---|
WakeLockFacade¶
Acquires a full wake lock (CPU on, screen bright, keyboard bright)
Acquires a partial wake lock (CPU on)
Acquires a bright wake lock (CPU on, screen bright)
Acquires a dim wake lock (CPU on, screen dim)
Releases the wake lock
WifiFacade¶
Returns the list of access points found during the most recent Wifi scan
Acquires a full Wifi lock
Acquires a scan only Wifi lock
Releases a previously acquired Wifi lock
Starts a scan for Wifi access points
Returns: | True if the scan was initiated successfully |
---|
checkWifiState ( ) ¶
Checks Wifi state
Returns: | True if Wifi is enabled |
---|
toggleWifiState ( enabled ) ¶
Toggle Wifi on and off
Parameters: | enabled(optional) (bool) – enabled |
---|---|
Returns: | True if Wifi is enabled |
wifiDisconnect ( ) ¶
Disconnects from the currently active access point
Returns: | True if the operation succeeded |
---|
wifiGetConnectionInfo ( ) ¶
Returns information about the currently active access point
Returns information about the currently active access point
Returns: | True if the operation succeeded |
---|
wifiReconnect ( ) ¶
Reconnects to the currently active access point
Returns: | True if the operation succeeded |
---|
BatteryManagerFacade¶
Returns the most recently recorded battery data
Starts tracking battery state
Stops tracking battery state
Returns the most recently received battery status data: 1 — unknown; 2 — charging; 3 — discharging; 4 — not charging; 5 — full
Returns the most recently received battery health data: 1 — unknown; 2 — good; 3 — overheat; 4 — dead; 5 — over voltage; 6 — unspecified failure
Returns the most recently received plug type data: -1 — unknown 0 — unplugged 1 — power source is an AC charger 2 — power source is a USB port
Returns the most recently received battery presence data
Returns the most recently received battery level (percentage)
Returns the most recently received battery voltage
Returns the most recently received battery temperature
Returns the most recently received battery technology data
ActivityResultFacade¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultByte ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultShort ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultChar ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultInteger ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultLong ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultFloat ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultDouble ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultString ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultBooleanArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultByteArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultShortArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultCharArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultIntegerArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultLongArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultFloatArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultDoubleArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultStringArray ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
setResultSerializable ( resultCode, resultValue ) ¶
Sets the result of a script execution. Whenever the script APK is called via startActivityForResult(), the resulting intent will contain SCRIPT_RESULT extra with the given value
Parameters: |
|
---|
MediaPlayerFacade¶
Control¶
Open a media file
Parameters: |
|
---|---|
Returns: |
mediaPlayPause ( tag ) ¶
pause playing media file
Parameters: | tag (str) – string identifying resource (default=default) |
---|---|
Returns: | true if successful |
mediaPlayStart ( tag ) ¶
start playing media file
Parameters: | tag (str) – string identifying resource (default=default) |
---|---|
Returns: | true if successful |
mediaPlayClose ( tag ) ¶
Close media file
Parameters: | tag (str) – string identifying resource (default=default) |
---|---|
Returns: | true if successful |
mediaIsPlaying ( tag ) ¶
Checks if media file is playing
Parameters: | tag (str) – string identifying resource (default=default) |
---|---|
Returns: | true if successful |
mediaPlaySetLooping ( enabled, tag ) ¶
Parameters: |
|
---|---|
Returns: |
mediaPlaySeek ( msec, tag ) ¶
Seek To Position
Parameters: |
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Returns: |
Parameters: | tag (str) – string identifying resource (default=default) |
---|---|
Returns: | Media Information |
mediaPlayList ( ) ¶
Lists currently loaded media
Returns: | List of Media Tags |
---|
PreferencesFacade¶
Read a value from shared preferences
Parameters: |
|
---|
prefPutValue ( key, value, filename ) ¶
Write a value to shared preferences
Parameters: |
|
---|
prefGetAll ( filename ) ¶
Get list of Shared Preference Values
Parameters: | filename(optional) (str) – Desired preferences file. If not defined, uses the default Shared Preferences. |
---|
QPyInterfaceFacade¶
Execute a qpython script by absolute path
Parameters: | script (str) – The absolute path of the qpython script |
---|---|
Returns: | bool |
TextToSpeechFacade¶
Speaks the provided message via TTS
Parameters: | message (str) – message |
---|
ttsIsSpeaking ( ) ¶
Returns True if speech is currently in progress
EyesFreeFacade¶
Speaks the provided message via TTS
Parameters: | message (str) – message |
---|
BluetoothFacade¶
Returns active Bluetooth connections
bluetoothWriteBinary ( base64, connID ) ¶
Send bytes over the currently open Bluetooth connection
Parameters: |
|
---|
bluetoothReadBinary ( bufferSize, connID ) ¶
Read up to bufferSize bytes and return a chunked, base64 encoded string
Parameters: |
|
---|
bluetoothConnect ( uuid, address ) ¶
Connect to a device over Bluetooth. Blocks until the connection is established or fails
Parameters: |
|
---|---|
Returns: |
bluetoothAccept ( uuid, timeout ) ¶
Listens for and accepts a Bluetooth connection. Blocks until the connection is established or fails
Parameters: |
|
---|
bluetoothMakeDiscoverable ( duration ) ¶
Requests that the device be discoverable for Bluetooth connections
Parameters: | duration (int) – period of time, in seconds, during which the device should be discoverable (default=300) |
---|
bluetoothWrite ( ascii, connID ) ¶
Sends ASCII characters over the currently open Bluetooth connection
Parameters: |
|
---|
bluetoothReadReady ( connID ) ¶
Sends ASCII characters over the currently open Bluetooth connection
Parameters: |
|
---|
bluetoothRead ( bufferSize, connID ) ¶
Read up to bufferSize ASCII characters
Parameters: |
|
---|
bluetoothReadLine ( connID ) ¶
Read the next line
Parameters: | connID(optional) (str) – Connection id |
---|
bluetoothGetRemoteDeviceName ( address ) ¶
Queries a remote device for it’s name or null if it can’t be resolved
Parameters: | address (str) – Bluetooth Address For Target Device |
---|
bluetoothGetLocalName ( ) ¶
Gets the Bluetooth Visible device name
Sets the Bluetooth Visible device name, returns True on success
Parameters: | name (str) – New local name |
---|
bluetoothGetScanMode ( ) ¶
Gets the scan mode for the local dongle. Return values: -1 when Bluetooth is disabled. 0 if non discoverable and non connectable. 1 connectable non discoverable. 3 connectable and discoverable.
Returns the name of the connected device
Parameters: | connID (str) – Connection id |
---|
checkBluetoothState ( ) ¶
Checks Bluetooth state
Returns: | True if Bluetooth is enabled |
---|
toggleBluetoothState ( enabled, prompt ) ¶
Toggle Bluetooth on and off
Parameters: |
|
---|---|
Returns: |
bluetoothStop ( connID ) ¶
Stops Bluetooth connection
Parameters: | connID (str) – Connection id |
---|
bluetoothGetLocalAddress ( ) ¶
Returns the hardware address of the local Bluetooth adapter
Start the remote device discovery process
Returns: | true on success, false on error |
---|
bluetoothDiscoveryCancel ( ) ¶
Cancel the current device discovery process
Returns: | true on success, false on error |
---|
bluetoothIsDiscovering ( ) ¶
Return true if the local Bluetooth adapter is currently in the device discovery process
SignalStrengthFacade¶
Starts tracking signal strengths
Returns the current signal strengths
Returns: | A map of gsm_signal_strength |
---|
stopTrackingSignalStrengths ( ) ¶
Stops tracking signal strength
WebCamFacade¶
Starts an MJPEG stream and returns a Tuple of address and port for the stream
Parameters: |
|
---|
webcamAdjustQuality ( resolutionLevel, jpegQuality ) ¶
Adjusts the quality of the webcam stream while it is running
Parameters: |
|
---|
cameraStartPreview ( resolutionLevel, jpegQuality, filepath ) ¶
Start Preview Mode. Throws ‘preview’ events
Parameters: |
|
---|---|
Returns: |
cameraStopPreview ( ) ¶
Stop the preview mode
UiFacade¶
Dialog¶
Create a text input dialog
Parameters: |
|
---|
dialogCreatePassword ( title, message ) ¶
Create a password input dialog
Parameters: |
|
---|
dialogGetInput ( title, message, defaultText ) ¶
Create a password input dialog
Parameters: |
|
---|
dialogGetPassword ( title, message ) ¶
Queries the user for a password
Parameters: |
|
---|
dialogCreateSeekBar ( start, maximum, title ) ¶
Create seek bar dialog
Parameters: |
|
---|
dialogCreateTimePicker ( hour, minute, is24hour ) ¶
Create time picker dialog
Parameters: |
|
---|
dialogCreateDatePicker ( year, month, day ) ¶
Create date picker dialog
Parameters: |
|
---|
Data structs QPython NFC json result
APIs
dialogCreateNFCBeamMaster ( title, message, inputType ) ¶
Create a dialog where you could create a qpython beam master
Parameters: |
|
---|
NFCBeamMessage ( content, title, message ) ¶
Create a dialog where you could create a qpython beam master
Parameters: |
|
---|
dialogCreateNFCBeamSlave ( title, message ) ¶
Create a qpython beam slave
Parameters: |
|
---|
Progress¶
Create a spinner progress dialog
Parameters: |
|
---|
dialogSetCurrentProgress ( current ) ¶
Set progress dialog current value
Parameters: | current (int) – current |
---|
dialogSetMaxProgress ( max ) ¶
Set progress dialog maximum value
Parameters: | max (int) – max |
---|
dialogCreateHorizontalProgress ( title, message, maximumProgress ) ¶
Create a horizontal progress dialog
Parameters: |
|
---|
Alert¶
Create alert dialog
Parameters: |
|
---|
Dialog Control¶
Set alert dialog positive button text
Parameters: | text (str) – text |
---|
dialogSetNegativeButtonText ( text ) ¶
Set alert dialog negative button text
Parameters: | text (str) – text |
---|
dialogSetNeutralButtonText ( text ) ¶
Set alert dialog button text
Parameters: | text (str) – text |
---|
dialogSetItems ( items ) ¶
Set alert dialog list items
Parameters: | items (list) – items |
---|
dialogSetSingleChoiceItems ( items, selected ) ¶
Set alert dialog list items
Parameters: |
|
---|
dialogSetMultiChoiceItems ( items, selected ) ¶
Set dialog multiple choice items and selection
Parameters: |
|
---|
addContextMenuItem ( label, event, eventData ) ¶
Adds a new item to context menu
Parameters: |
|
---|
addOptionsMenuItem ( label, event, eventData, iconName ) ¶
Adds a new item to context menu
Parameters: |
|
---|
dialogGetResponse ( ) ¶
Returns dialog response
This method provides list of items user selected
Layout¶
Show Full Screen
Parameters: | layout (string) – String containing View layout |
---|
fullDismiss ( ) ¶
Dismiss Full Screen
Get Fullscreen Properties
Get fullscreen properties for a specific widget
Parameters: | id (str) – id of layout widget |
---|
fullSetProperty ( id ) ¶
Set fullscreen widget property
Parameters: |
|
---|
fullSetList ( id, list ) ¶
Attach a list to a fullscreen widget
Parameters: |
|
---|
fullKeyOverride ( keycodes, enable ) ¶
Override default key actions
Parameters: |
|
---|
WebView¶
Display a WebView with the given URL
Parameters: |
|
---|
USB Host Serial Facade¶
QPython 1.3.1+ and QPython3 1.0.3+ contains this feature
SL4A Facade for USB Serial devices by Android USB Host API.
It control the USB-Serial like devices from Andoroid which has USB Host Controller .
Requirements¶
Android device which has USB Host controller (and enabled in that firmware).
Android 4.0 (API14) or later.
USB Serial devices (see [Status](#Status)).
USB Serial devices were not handled by Android kernel.
> I heard some android phone handle USB Serial devices > make /dev/ttyUSB0 in kernel level. > In this case, Android does not be able to handle the device > from OS level.
please check Android Applications be able to grab the target USB Devices, such as USB Device Info.
Status¶
probably work with USB CDC, like FTDI, Arduino or else.
2012/09/10: work with 78K0F0730 device (new RL78) with Tragi BIOS board.
2012/09/24: work with some pl2303 devcies.
Author¶
This facade developped by Kuri65536 you can see the commit log in it.
Returns USB devices reported by USB Host API.
Returns: | Returns “Map of id and string information Map |
---|
usbserialDisconnect ( connID ) ¶
Disconnect all USB-device
Parameters: | connID (str) – connection ID |
---|
usbserialActiveConnections ( ) ¶
Returns active USB-device connections.
Returns: | Returns “Active USB-device connections by Map UUID vs device-name.” |
---|
usbserialWriteBinary ( base64, connID ) ¶
Send bytes over the currently open USB Serial connection.
Parameters: |
|
---|
usbserialReadBinary ( bufferSize, connID ) ¶
Read up to bufferSize bytes and return a chunked, base64 encoded string
Parameters: |
|
---|
usbserialConnect ( hash, options ) ¶
Connect to a device with USB-Host. request the connection and exit
Parameters: |
|
---|---|
Returns: |
usbserialHostEnable ( ) ¶
Requests that the host be enable for USB Serial connections.
Returns: | True if the USB Device is accesible |
---|
usbserialWrite ( String ascii, String connID ) ¶
Sends ASCII characters over the currently open USB Serial connection
Parameters: |
|
---|
usbserialReadReady ( connID ) ¶
Parameters: | connID (str) – |
---|---|
Returns: | True if the next read is guaranteed not to block |
usbserialRead ( connID, bufferSize ) ¶
Read up to bufferSize ASCII characters.
Parameters: |
|
---|
usbserialGetDeviceName ( connID ) ¶
Queries a remote device for it’s name or null if it can’t be resolved
Источник