Skip to content
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.

environment A 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.
 
getClipboard Read text from the clipboard.
returns: (String) The text in the clipboard.
getConstants Get list of constants (static final fields) for a class
classname (String) Class to get constants from
getInput Queries 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.
getIntent Returns the intent that launched the script.
getPackageVersion Returns package version name.
packageName (String)
getPackageVersionCode Returns package version code.
packageName (String)
getPassword Queries 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.
log Writes message to logcat.
message (String)
makeIntent Create 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
makeToast Displays a short-duration Toast notification.
message (String)
notify Displays a notification that will be canceled when the user clicks on it.
title (String) title
message (String)
requiredVersion Checks if version of SL4A is greater than or equal to the specified version.
requiredVersion (Integer)
sendBroadcast Send 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)
sendBroadcastIntent Send Broadcast Intent
intent (Intent) Intent in the format as returned from makeIntent
sendEmail Launches 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)
setClipboard Put text in the clipboard.
text (String)
Creates a new AndroidFacade that simplifies the interface to various Android APIs.
startActivity Starts 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.
startActivityForResult Starts 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.
startActivityForResultIntent Starts 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.
startActivityIntent Start Activity using Intent
intent (Intent) Intent in the format as returned from makeIntent
wait (Boolean) block until the user exits the started activity (optional)
vibrate Vibrates the phone or a specified duration in milliseconds.
duration (Integer) duration in milliseconds (default=300)
Clone this wiki locally