Android scripting environment ase

Содержание
  1. Android scripting environment ase
  2. Latest commit
  3. Git stats
  4. Files
  5. README.md
  6. About
  7. …code, cg, electronics, 3d printing…
  8. Installing the Android Scripting Environment on the Android Emulator
  9. #1: Install the Android SDK:
  10. #2: Create an Android Virtual Device (AVD):
  11. #3: Install the Android Scripting Environment (ASE):
  12. #4: Configure the ASE:
  13. In Conclusion…
  14. Index of reference pages:
  15. opensource.google.com
  16. Google Open Source Blog
  17. Introducing Android Scripting Environment
  18. Monday, June 8, 2009
  19. AndroidFacade¶
  20. Clipboard APIs¶
  21. Intent & startActivity APIs¶
  22. SendBroadcast APIs¶
  23. Vibrate¶
  24. NetworkStatus¶
  25. PackageVersion APIs¶
  26. System APIs¶
  27. SendEmail¶
  28. Toast, getInput, getPassword, notify APIs¶
  29. ApplicationManagerFacade¶
  30. Manager APIs¶
  31. CameraFacade¶
  32. CommonIntentsFacade¶
  33. Barcode¶
  34. View APIs¶
  35. ContactsFacade¶
  36. EventFacade¶
  37. LocationFacade¶
  38. Providers APIs¶
  39. Location APIs¶
  40. PhoneFacade¶
  41. PhoneStat APIs¶
  42. Call & Dia APIs¶
  43. Get information APIs¶
  44. MediaRecorderFacade¶
  45. Audio¶
  46. Video APIs¶
  47. SensorManagerFacade¶
  48. Start & Stop¶
  49. Read data APIs¶
  50. SettingsFacade¶
  51. Screen¶
  52. AirplanerMode¶
  53. Ringer Silent Mode¶
  54. Vibrate Mode¶
  55. Ringer & Media Volume¶
  56. Screen Brightness¶
  57. SmsFacade¶
  58. SpeechRecognitionFacade¶
  59. ToneGeneratorFacade¶
  60. WakeLockFacade¶
  61. WifiFacade¶
  62. BatteryManagerFacade¶
  63. ActivityResultFacade¶
  64. MediaPlayerFacade¶
  65. Control¶
  66. Get Information¶
  67. PreferencesFacade¶
  68. QPyInterfaceFacade¶
  69. TextToSpeechFacade¶
  70. EyesFreeFacade¶
  71. BluetoothFacade¶
  72. SignalStrengthFacade¶
  73. WebCamFacade¶
  74. UiFacade¶
  75. Dialog¶
  76. Progress¶
  77. Alert¶
  78. Dialog Control¶
  79. Layout¶
  80. WebView¶
  81. USB Host Serial Facade¶
  82. Requirements¶
  83. Status¶
  84. 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

An object representing an Intent

Returns the intent that launched the script

Starts an activity and returns the result

Parameters:
  • action (str) – action
  • uri(Optional) (str) – uri
  • type(Optional) (str) – MIME type/subtype of the URI
  • extras(Optional) (object) – a Map of extras to add to the Intent
  • categories(Optional) (list) – a List of categories to add to the Intent
  • packagename(Optional) (str) – name of package. If used, requires classname to be useful
  • classname(Optional) (str) – name of class. If used, requires packagename to be useful
  • flags(Optional) (int) – Intent flags
Returns:

A Map representation of the result Intent

Starts an activity and returns the result

Parameters:
  • action (str) – action
  • uri(Optional) (str) – uri
  • type(Optional) (str) – MIME type/subtype of the URI
  • extras(Optional) (object) – a Map of extras to add to the Intent
  • packagename(Optional) (str) – name of package. If used, requires classname to be useful
  • classname(Optional) (str) – name of class. If used, requires packagename to be useful
Returns:
Parameters: intent (Intent) – Intent in the format as returned from makeIntent
Returns: A Map representation of the result Intent

Starts an activity

Parameters:
  • intent (Intent) – Intent in the format as returned from makeIntent
  • wait(Optional) (bool) – block until the user exits the started activity

Starts an activity

Parameters:
  • action (str) – action
  • uri(Optional) (str) – uri
  • type(Optional) (str) – MIME type/subtype of the URI
  • extras(Optional) (object) – a Map of extras to add to the Intent
  • wait(Optional) (bool) – block until the user exits the started activity
  • packagename(Optional) (str) – name of package. If used, requires classname to be useful
  • classname(Optional) (str) – name of class. If used, requires packagename to be useful

SendBroadcast APIs¶

Send a broadcast

Parameters:
  • action (str) – action
  • uri(Optional) (str) – uri
  • type(Optional) (str) – MIME type/subtype of the URI
  • extras(Optional) (object) – a Map of extras to add to the Intent
  • packagename(Optional) (str) – name of package. If used, requires classname to be useful
  • classname(Optional) (str) – name of class. If used, requires packagename to be useful

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:
  • to (str) – A comma separated list of recipients
  • subject (str) – subject
  • body (str) – mail body
  • attachmentUri(Optional) (str) – message

Toast, getInput, getPassword, notify APIs¶

Displays a short-duration Toast notification

Parameters: message (str) – message

Queries the user for a text input

Parameters:
  • title (str) – title of the input box
  • message (str) – message to display above the input box

Queries the user for a password

Parameters:
  • title (str) – title of the input box
  • message (str) – message to display above the input box

Displays a notification that will be canceled when the user clicks on it

Parameters:
  • title (str) – title
  • message (str) – message
  • url(optional) (str) – url

:: 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:
  • destinationAddress (str) – typically a phone number
  • text (str) –

smsGetMessageCount ( unreadOnly, folder ) ¶

Returns the number of messages

Parameters:
  • unreadOnly (bool) – typically a phone number
  • folder(optional) (str) – default “inbox”

smsGetMessageIds ( unreadOnly, folder ) ¶

Returns a List of all message IDs

Parameters:
  • unreadOnly (bool) – typically a phone number
  • folder(optional) (str) – default “inbox”

smsGetMessages ( unreadOnly, folder, attributes ) ¶

Returns a List of all messages

a List of messages as Maps

Parameters:
  • unreadOnly (bool) – typically a phone number
  • folder (str) – default “inbox”
  • attributes(optional) (list) – attributes
Returns:

smsGetMessageById ( id, attributes ) ¶

Returns message attributes

a List of messages as Maps

Parameters:
  • id (int) – message ID
  • attributes(optional) (list) – attributes
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

number of messages marked read

SpeechRecognitionFacade¶

Recognizes user’s speech and returns the most likely result

Parameters:
  • ids (list) – List of message IDs to mark as read
  • read (bool) – true or false
Returns:

An empty string in case the speech cannot be recongnized

ToneGeneratorFacade¶

Generate DTMF tones for the given phone number

Parameters:
  • prompt(optional) (str) – text prompt to show to the user when asking them to speak
  • language(optional) (str) – language override to inform the recognizer that it should expect speech in a language different than the one set in the java.util.Locale.getDefault()
  • languageModel(optional) (str) – informs the recognizer which speech model to prefer (see android.speech.RecognizeIntent)
Returns:
Parameters:
  • phoneNumber (str) – phone number
  • toneDuration(optional) (int) – default 100, duration of each tone in milliseconds

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

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:
  • resultCode (int) –
  • resultValue (byte) –

MediaPlayerFacade¶

Control¶

Open a media file

true if play successful

Parameters:
  • url (str) – url of media resource
  • tag(optional) (str) – string identifying resource (default=default)
  • play(optional) (bool) – start playing immediately
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 ) ¶

True if successful

Parameters:
  • enabled (bool) – default true
  • tag (str) – string identifying resource (default=default)
Returns:

mediaPlaySeek ( msec, tag ) ¶

Seek To Position

New Position (in ms)

Get Information¶

Information on current media

Parameters:
  • msec (int) – default true
  • tag (str) – string identifying resource (default=default)
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:
  • key (str) – key
  • filename(optional) (str) – Desired preferences file. If not defined, uses the default Shared Preferences.

prefPutValue ( key, value, filename ) ¶

Write a value to shared preferences

Parameters:
  • key (str) – key
  • value (str) – value
  • filename(optional) (str) – Desired preferences file. If not defined, uses the default Shared Preferences.

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:
  • base64 (str) – A base64 encoded String of the bytes to be sent
  • connID(optional) (str) – Connection id

bluetoothReadBinary ( bufferSize, connID ) ¶

Read up to bufferSize bytes and return a chunked, base64 encoded string

Parameters:
  • bufferSize (int) – default 4096
  • connID(optional) (str) – Connection id

bluetoothConnect ( uuid, address ) ¶

Connect to a device over Bluetooth. Blocks until the connection is established or fails

True if the connection was established successfully

Parameters:
  • uuid (str) – The UUID passed here must match the UUID used by the server device
  • address(optional) (str) – The user will be presented with a list of discovered devices to choose from if an address is not provided
Returns:

bluetoothAccept ( uuid, timeout ) ¶

Listens for and accepts a Bluetooth connection. Blocks until the connection is established or fails

Parameters:
  • uuid (str) – The UUID passed here must match the UUID used by the server device
  • timeout (int) – How long to wait for a new connection, 0 is wait for ever (default=0)

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:
  • ascii (str) – text
  • connID (str) – Connection id

bluetoothReadReady ( connID ) ¶

Sends ASCII characters over the currently open Bluetooth connection

Parameters:
  • ascii (str) – text
  • connID (str) – Connection id

bluetoothRead ( bufferSize, connID ) ¶

Read up to bufferSize ASCII characters

Parameters:
  • bufferSize (int) – default=4096
  • connID(optional) (str) – Connection id

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

True if Bluetooth is enabled

Parameters:
  • enabled (bool) –
  • prompt (str) – Prompt the user to confirm changing the Bluetooth state, default=true
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:
  • resolutionLevel (int) – increasing this number provides higher resolution (default=0)
  • jpegQuality (int) – a number from 0-10 (default=20)
  • port (int) – If port is specified, the webcam service will bind to port, otherwise it will pick any available port (default=0)

webcamAdjustQuality ( resolutionLevel, jpegQuality ) ¶

Adjusts the quality of the webcam stream while it is running

Parameters:
  • resolutionLevel (int) – increasing this number provides higher resolution (default=0)
  • jpegQuality (int) – a number from 0-10 (default=20)

cameraStartPreview ( resolutionLevel, jpegQuality, filepath ) ¶

Start Preview Mode. Throws ‘preview’ events

True if successful

Parameters:
  • resolutionLevel (int) – increasing this number provides higher resolution (default=0)
  • jpegQuality (int) – a number from 0-10 (default=20)
  • filepath (str) – Path to store jpeg files
Returns:

cameraStopPreview ( ) ¶

Stop the preview mode

UiFacade¶

Dialog¶

Create a text input dialog

Parameters:
  • title (str) – title of the input box
  • message (str) – message to display above the input box
  • defaultText(optional) (str) – text to insert into the input box
  • inputType(optional) (str) – type of input data, ie number or text

dialogCreatePassword ( title, message ) ¶

Create a password input dialog

Parameters:
  • title (str) – title of the input box
  • message (str) – message to display above the input box

dialogGetInput ( title, message, defaultText ) ¶

Create a password input dialog

Parameters:
  • title (str) – title of the input box
  • message (str) – message to display above the input box
  • defaultText(optional) (str) – text to insert into the input box

dialogGetPassword ( title, message ) ¶

Queries the user for a password

Parameters:
  • title (str) – title of the password box
  • message (str) – message to display above the input box

dialogCreateSeekBar ( start, maximum, title ) ¶

Create seek bar dialog

Parameters:
  • start (int) – default=50
  • maximum (int) – default=100
  • title (int) – title

dialogCreateTimePicker ( hour, minute, is24hour ) ¶

Create time picker dialog

Parameters:
  • hour (int) – default=0
  • miute (int) – default=0
  • is24hour (bool) – default=false

dialogCreateDatePicker ( year, month, day ) ¶

Create date picker dialog

Parameters:
  • year (int) – default=1970
  • month (int) – default=1
  • day (int) – default=1

Data structs QPython NFC json result

APIs

dialogCreateNFCBeamMaster ( title, message, inputType ) ¶

Create a dialog where you could create a qpython beam master

Parameters:
  • title (str) – title of the input box
  • message (str) – message to display above the input box
  • inputType(optional) (str) – type of input data, ie number or text

NFCBeamMessage ( content, title, message ) ¶

Create a dialog where you could create a qpython beam master

Parameters:
  • content (str) – message you want to sent
  • title (str) – title of the input box
  • message (str) – message to display above the input box
  • inputType(optional) (str) – type of input data, ie number or text

dialogCreateNFCBeamSlave ( title, message ) ¶

Create a qpython beam slave

Parameters:
  • title (str) – title of the input box
  • message (str) – message to display above the input box

Progress¶

Create a spinner progress dialog

Parameters:
  • message(optional) (str) – message
  • maximunProgress(optional) (int) – dfault=100

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:
  • title(optional) (str) – title
  • message(optional) (str) – message
  • maximunProgress(optional) (int) – dfault=100

Alert¶

Create alert dialog

Parameters:
  • title(optional) (str) – title
  • message(optional) (str) – message
  • maximunProgress(optional) (int) – dfault=100

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:
  • items (list) – items
  • selected (int) – selected item index (default=0)

dialogSetMultiChoiceItems ( items, selected ) ¶

Set dialog multiple choice items and selection

Parameters:
  • items (list) – items
  • selected (int) – selected item index (default=0)

addContextMenuItem ( label, event, eventData ) ¶

Adds a new item to context menu

Parameters:
  • label (str) – label for this menu item
  • event (str) – event that will be generated on menu item click
  • eventData (object) – event object

addOptionsMenuItem ( label, event, eventData, iconName ) ¶

Adds a new item to context menu

Parameters:
  • label (str) – label for this menu item
  • event (str) – event that will be generated on menu item click
  • eventData (object) – event object
  • iconName (str) – Android system menu icon, see http://developer.android.com/reference/android/R.drawable.html

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:
  • id (str) – id of layout widget
  • property (str) – name of property to set
  • value (str) – value to set property to

fullSetList ( id, list ) ¶

Attach a list to a fullscreen widget

Parameters:
  • id (str) – id of layout widget
  • list (list) – List to set

fullKeyOverride ( keycodes, enable ) ¶

Override default key actions

Parameters:
  • keycodes (str) – id of layout widget
  • enable (bool) – List to set (default=true)

WebView¶

Display a WebView with the given URL

Parameters:
  • url (str) – url
  • wait(optional) (bool) – block until the user exits the WebView

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:
  • base64 (str) –
  • connId (str) –

usbserialReadBinary ( bufferSize, connID ) ¶

Read up to bufferSize bytes and return a chunked, base64 encoded string

Parameters:
  • bufferSize (int) –
  • connId (str) –

usbserialConnect ( hash, options ) ¶

Connect to a device with USB-Host. request the connection and exit

Returns messages the request status

Parameters:
  • hash (str) –
  • options (str) –
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:
  • ascii (str) –
  • connID (str) –

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:
  • connID (str) –
  • bufferSize (int) –

usbserialGetDeviceName ( connID ) ¶

Queries a remote device for it’s name or null if it can’t be resolved

Источник

Читайте также:  Стиль букв для андроида
Оцените статью