Skip to content

SL4A AndroidFacade

michael edited this page Nov 9, 2015 · 3 revisions

Some general purpose Android routines.


Intents Intents are returned as a map, in the following form:
  • action - action.
  • data - url
  • type - mime type
  • packagename - name of package. If used, requires classname to be useful (optional)
  • classname - name of class. If used, requires packagename to be useful (optional)
  • categories - list of categories
  • extras - map of extras
  • flags - integer flags.

An intent can be built using the makeIntent call, but can also be constructed exterally.

environmentA map of various useful environment details
Map returned:
 TZ = Timezone
id = Timezone ID
display = Timezone display name
offset = Offset from UTC (in ms)
SDK = SDK Version
download = default download path
appcache = Location of application cache sdcard = Space on sdcard
availblocks = Available blocks
blockcount = Total Blocks
blocksize = size of block.
getClipboardRead text from the clipboard.
returns: (String) The text in the clipboard.
getConstantsGet list of constants (static final fields) for a class
classname (String) Class to get constants from
getInputQueries the user for a text input.
title (String) title of the input box (default=SL4A Input)
message (String) message to display above the input box (default=Please enter value:)
Deprecated in r3. Use dialogGetInput instead.
getIntentReturns the intent that launched the script.
getPackageVersionReturns package version name.
packageName (String)
getPackageVersionCodeReturns package version code.
packageName (String)
getPasswordQueries the user for a password.
title (String) title of the input box (default=SL4A Password Input)
message (String) message to display above the input box (default=Please enter password:)
Deprecated in r3. Use dialogGetPassword instead.
logWrites message to logcat.
message (String)
makeIntentCreate an Intent.
action (String)
uri (String) (optional)
type (String) MIME type/subtype of the URI (optional)
extras (JSONObject) a Map of extras to add to the Intent (optional)
categories (JSONArray) a List of categories to add to the Intent (optional)
packagename (String) name of package. If used, requires classname to be useful (optional)
classname (String) name of class. If used, requires packagename to be useful (optional)
flags (Integer) Intent flags (optional)
returns: (Intent) An object representing an Intent
makeToastDisplays a short-duration Toast notification.
message (String)
notifyDisplays a notification that will be canceled when the user clicks on it.
title (String) title
message (String)
requiredVersionChecks if version of SL4A is greater than or equal to the specified version.
requiredVersion (Integer)
sendBroadcastSend a broadcast.
action (String)
uri (String) (optional)
type (String) MIME type/subtype of the URI (optional)
extras (JSONObject) a Map of extras to add to the Intent (optional)
packagename (String) name of package. If used, requires classname to be useful (optional)
classname (String) name of class. If used, requires packagename to be useful (optional)
sendBroadcastIntentSend Broadcast Intent
intent (Intent) Intent in the format as returned from makeIntent
sendEmailLaunches an activity that sends an e-mail message to a given recipient.
to (String) A comma separated list of recipients.
subject (String)
body (String)
attachmentUri (String) (optional)
setClipboardPut text in the clipboard.
text (String)
Creates a new AndroidFacade that simplifies the interface to various Android APIs.
startActivityStarts an activity.
action (String)
uri (String) (optional)
type (String) MIME type/subtype of the URI (optional)
extras (JSONObject) a Map of extras to add to the Intent (optional)
wait (Boolean) block until the user exits the started activity (optional)
packagename (String) name of package. If used, requires classname to be useful (optional)
classname (String) name of class. If used, requires packagename to be useful (optional)
packagename and classname, if provided, are used in a 'setComponent' call.
startActivityForResultStarts an activity and returns the result.
action (String)
uri (String) (optional)
type (String) MIME type/subtype of the URI (optional)
extras (JSONObject) a Map of extras to add to the Intent (optional)
packagename (String) name of package. If used, requires classname to be useful (optional)
classname (String) name of class. If used, requires packagename to be useful (optional)
returns: (Intent) A Map representation of the result Intent.
startActivityForResultIntentStarts an activity and returns the result.
intent (Intent) Intent in the format as returned from makeIntent
returns: (Intent) A Map representation of the result Intent.
startActivityIntentStart Activity using Intent
intent (Intent) Intent in the format as returned from makeIntent
wait (Boolean) block until the user exits the started activity (optional)
vibrateVibrates the phone or a specified duration in milliseconds.
duration (Integer) duration in milliseconds (default=300)

Clone this wiki locally