User Tools

Site Tools


Sidebar

Privacy Policy

News

Version 2.50 is out since Jan 1st 2022


Frequently Asked Questions


Namespaces

Note for contributors

If you wish to create a new page in the DroidScript wiki, please click on the most appropriate namespace above and follow the notes for contributors there.

Because of spam, it has been necessary to add a CAPTCHA to the registration form and the save option for editing pages. You will not need to prove you are human if you are logged in, so please register.

Please feel free to improve any existing page, as well as adding new pages to increase the sum of public knowledge about DroidScript.

Formatting Syntax

built_in:app

The app object

Methods

The following table lists the methods available from the app object.

Method Description/Sample added
app._Extract( p1 )
app.AddLayout( layout ) Adds a layout to the App.
app.Alert( text, title ) Shows a message on the screen with an OK button and text given in text parameter with optional title.
app.Broadcast( p1,p2 )
app.Call( number ) Makes phone call to a number.
app.ClearData(file) clears app.SaveText/SaveNumber..etc 1.29
app.CopyFile( src, dest ) Copy a file src from the app to the dest folder on the SD-card.
app.CopyFolder( src,dest,overwrite )
app.CheckLicense() The app.CheckLicense( key ) method will trigger a standard Google Play license check for the running application (if it is a paid App).
You need to pass in the long key which can be found in the “Services and API's” section of the developer console.
If the App is not licensed (for example someone just got hold of a copy of your APK and installed it) then it will show them a dialog asking them to purchase the App from Google Play and then close the App.
app.CreateAudioRecorder()
app.CreateBluetoothList( p1 )
app.CreateBluetoothSerial( mode )
app.CreateButton( text, width, height, options )
app.CreateCameraView( width,height,options )
app.CreateCheckBox( text, width, height, options )
app.CreateCrypt( options )
app.CreateDebug()
app.CreateDialog( title,options ) If you add the “NoCancel” in options to the CreateDialog method, it will prevent back keys and touches outside the dialog area from closing the dialog. You can then add a “OK” or “Close” button to the dialog, so you can close the dialog manually by calling the dlg.Hide() or dlg.Dismiss() methods. There is also a “NoTitle” option.
app.CreateDownloader()
app.CreateEmail( ownmail,mailpass )
app.CreateFile(file,mode) 1.23b
app.CreateGLView( width,height,options )
app.CreateImage( file,width,height,options,w,h ) new “Alias” option since V1.23b
app.CreateIOIO( p1 )
app.CreateLayout( type,options )
app.CreateList( list,width,height,options ) list is a comma seperated list
app.CreateListDialog( headertext,list,p3 )
app.CreateListView( list,title,options )
app.CreateLocator( type,p2 )
app.CreateMediaPlayer()
app.CreateMediaStore()
app.CreateNetClient( p1 )
app.CreateNotification( options )
app.CreateNxt() Creates the NXT object is used to manage the connection between your Android phone/tablet and the Lego Mindstorms NXT brick.
app.CreateNxtRemote() Internal NXTRemote object. Use NXT object from app.CreateNXT()
app.CreateObject( name )
app.CreatePlayStore()
app.CreateScroller( width,height,p3 )
app.CreateSeekBar( width,height,p3 )
app.CreateSensor( type,options ) types: Accelerometer, MagneticField, Orientation, Light, Proximity, Temperature, GameRotation, GeomagneticRotation, Gravity, Gyroscope, HeartRate, Acceleration, Pressure, Humidity, RotationMotion, StepCounter, StepDetector
app.CreateService( packageName, classname, callback, options )
app.CreateShortcut( name,icon,script ) name is a title for the Shortcut,
icon needs the path to a picture for the Shortcut and
script is the fullpath to the js-file which should starting within Droidscript
app.CreateSmartWatch( p1 )
app.CreateSMS()
app.CreateSpeechRec( options ) option 'NoBeep' (only works on phones at moment).
app.CreateSpinner( list,width,height,options )
app.CreateSynth( p1 )
app.CreateSysProc( shell ) shell is name of command shell to use (e.g. “sh”). One system procedure can be created at startup and reused throughout the program's life.
app.CreateTabs( list,width,height,options )
app.CreateText( text,width,height,options )
app.CreateTextEdit( text,width,height,options )
app.CreateToggle( text,width,height,options )
app.CreateUSBSerial( baudRate,dataBits,stopBits,parity )
app.CreateVideoView( width,height,options )
app.CreateWebServer( p1,p2 ) new “Reflect” option since V1.23b
app.CreateWebView( width,height,options,zoom )
app.CreateYesNoDialog( text )
app.CreateZipUtil( mode )
app.Debug( text ) Sends text info to the Debug tab and debug your app.
app.DeleteDatabase(name)
app.DeleteFile( file ) Deletes a file. The file parameter needs the fullpath.
app.DeleteFile( "/sdcard/wftest.txt" );
app.DeleteFolder( folder )
app.DeleteFolder( "/sdcard/Temp" );
app.DestroyLayout( layout )
app.EnableBackKey( true/false ) Sets if your App will exit, if you press the Back-Key.
app.EnableBackKey( false );
app.DisableKeys(keyList) disables normal function of given keys 1.29
app.Execute( code ) This function is intended for use inside a WebView control to execute functions in the main script
Note: You should put quotes around the code you want executing too:
app.Execute( "Alert( 'Hi' )" );

or

app.Execute( "Alert( \"Hi\" )" );
app.Exit( p1 ) Stops your App.
app.ExtractAssets( src,dest,overwrite ) Copy content from one folder to another. If overwrite = true, then existing files in destination folder will be overwritten.
app.FileExists( file ) Checks if a file exist and returns “true” or “false”.
app.FolderExists( folder ) Checks if a folder exist and returns “true” or “false”.
app.GetAccounts() 1.25b
app.GetAppName() Returns the name of your App.
app.GetBatteryLevel() 1.29
app.GetAppPath() Returns the path of your App.
app.GetBuildNum() Returns the version number of the Android operating system currently running.
app.GetClipboardText() Returns the Text, which is copied to your Clipboard.
app.GetCountry()
app.GetCountryCode()
app.GetData( p1 )
app.GetDatabaseFolder()
app.GetDefaultOrientation() Returns the “normal” Orientation of the device.
app.GetDeviceId()
app.GetDisplayHeight() Returns your Display Height.Sample Get Device Infos
app.GetDisplayWidth() Returns your Display Width
Sample Get Device Infos
app.GetDSVersion() Returns the currently running version of DroidScript.
app.GetEnv()
app.GetExternalFolder() Returns the path to the External sd card.
app.GetFileDate( file ) Returns the date of a file (file needs the full path).
app.GetFileSize( file ) Returns the size of a file in bytes (file needs the full path).
app.GetFreeSpace( option ) Returns the free space in gigabytes. Parameter option can be: “internal” or “external”.
app.GetInternalFolder()
app.GetIPAddress() Returns the IP Address of your device.
app.GetJoystickName( id )
app.GetJoystickState( id,key )
app.GetLanguage()
app.GetLanguageCode()
app.GetLastButton()
app.GetLastCheckBox()
app.GetLastImage()
app.GetLastToggle()
app.GetMacAddress()
app.GetMediaFile(“MyApp”,“.png”) 1.23b
app.GetMetadata( file,keys )
app.GetModel() Sample Get Device Infos
app.GetName()
app.GetNotifyId() gets id of in-comming notification 1.29
app.GetObjects() Returns all Objects of your App
app.GetOptions()
app.GetOrientation() Returns the current orientation of the device
app.GetOSVersion() Returns the version number of the Android operating system currently running.Sample Get Device Infos
app.GetPackageName() 1.23b
app.GetPath()
app.GetPrivateFolder( name )
app.GetRingerMode()
app.GetRotation()
app.GetRunningApps() 1.29
app.GetRunningServices() 1.29
app.GetScreenDensity() Sample Get Device Infos
app.GetScreenHeight() Returns the Height of your device
Sample Get Device Infos
app.GetScreenWidth() Returns the Width of your device
Sample Get Device Infos
app.GetSharedFiles()
app.GetSharedText( p1 )
app.GetSpecialFolder( name ) 'DCIM','Pictures','Movies','Downloads' etc 1.29
app.GetTop()
app.GetUser()
app.GetVersion() Returns the version of the APK the code is running in. If not a built APK, returns the DroidScript version
app.GetVolume(stream) streams: alarm,dtmf,music,notification,ring,system,voicecall 1.25b
app.GoToSleep()
app.HideKeyboard( p1 )
app.HideProgress() Hides progress bar window shown by ShowProgress method.
app.HideProgressBar() Hides progress bar window shown by ShowProgressBar method.
app.IsBluetoothEnabled()
app.IsBluetoothOn() Checks if Bluetooth is on.
app.IsChrome() detects running in arc welded chrome 1.23b
app.IsFolder( folder ) Checks if folder is a file or folder.
app.IsKeyboardShown() 1.29
app.IsNewVersion()
app.IsPro()
app.IsScreenOn()
app.IsTablet() Check if the device is a tablet. Returns true or false. Sample Get Device Infos
app.IsWifiEnabled()
app.KillApp( file ) Delete the file
(file needs the fullpath)
app.ListFolder( path,filter,limit,options ) Lists all files and folders in a path, which match the filter and their count in path is less than the limit. options can be “FullPath”
app.LoadBoolean( valueName, default, id ) The LoadBoolean method loads and returns a boolean (true of false) value from the user's storage space under valueName. If there is no stored valueName, then method returns default value. Parameter id is an optional text parameter and allows sharing of data across multiple Apps when the same id is used by both apps.
app.LoadNumber( valueName, default, id ) The LoadNumber method loads and returns a numeric value from the user's storage space under valueName. If there is no stored valueName, then method returns default value. Parameter id is an optional text parameter and allows sharing of data across multiple Apps when the same id is used by both apps.
app.LoadPlugin( url )
app.LoadScript( url, callback )
app.LoadText( valueName, default, id ) The LoadText method loads and returns a text value from the user's storage space under valueName. If there is no stored valueName, then method returns default value. Parameter id is an optional text parameter and allows sharing of data across multiple Apps when the same id is used by both apps.
app.MakeFolder( fldr )
app.Odroid(p1,p2,p3)
app.OpenDatabase(name)
app.OpenFile( file,type,choose )
app.OpenUrl( url )
app.PreventScreenLock( truefalse )
app.PreventWifiSleep( p1 )
app.ReadFile( file, options )
app.RemoveLayout( layout )
app.RenameFile( filename,newname )
app.RenameFolder( foldername,newfoldername )
app.SaveBoolean( valueName,value,id ) The SaveBoolean method saves a boolean (true or false) value to the user's storage space under valueName. Parameter id is an optional text parameter and allows sharing of data across multiple Apps when the same id is used by both apps.
app.SaveNumber( valueName,value,id ) The SaveNumber method saves a numeric value to the user's storage space under valueName. Parameter id is an optional text parameter and allows sharing of data across multiple Apps when the same id is used by both apps.
app.SaveText( valueName,value,id ) The SaveText method saves a text value to the user's storage space under valueName. Parameter id is an optional text parameter and allows sharing of data across multiple Apps when the same id is used by both apps.
app.SendFile(file,subject,text) sends files to other Apps, user chooses 1.29
app.SendIntent( packageName, className, action, category, data, type, extras, options ) 1.23b
app.SendMail( address,subject,body,attach ) Sends an email message via the built in email app.
(Leave 4th parameter out if attachment is not required).
app.SendMessage(msg) 1.29
app.SetAlarm( type,id,callback,time,interval )
app.SetAutoBoot(TrueFalse) Calling app.SetAutoBoot( true ) method will cause DroidScript to be started automatically when your device boots.
The method will also work in your own apps if you build APKs.
app.SetAutoWifi(TrueFalse) The app.SetAutoWifi( true ) method will cause DroidScript to turn on the WiFi editor automatically
app.SetBluetoothEnabled(enable)
app.SetClipboardText( text ) Copy the Text to your Clipboard
app.SetData( name,value )
app.SetDebugEnabled( enable ) Switch off debugging for max speed.
(keep this on during developement)
app.SetDebugEnabled( false );
app.SetJoystickOptions( options )
app.SetMenu( list,p2 ) Parameter list is a comma separated list with the menupoints
This Sample demonstrates how to set a menu
app.SetOnBroadcast( callback )
app.SetOnError( callback )
app.SetOnKey(callback) reports key changes, including volume key 1.29
app.SetOptions(options)
app.SetOrientation( orient,callback ) Sets the orientation of the device. Parameter orient could be “Portrait”, “Landscape” or “Default”. After using this function rotating the phone/tablet will have no effect on the app's orientation. To unlock the orientation call the function again using the orientation “Default”. The callback function is invoked after orientation change.
app.SetRingerMode( mode ) use Normal, Vibrate or Silent to set the mode
app.SetScreenBrightness( level ) The SetScreenBrightness method sets the screen brightness for this App with a decimal value level between 0 and 1.
app.SetScreenMode( mode ) Set full screen mode.
app.SetScreenMode( "Full" ); 

new “Game” mode since V1.23b

app.SetSharedApp( p1 )
app.SetTitle( p1 ) This method is obsolete
app.SetVolume(stream,level) streams: alarm,dtmf,music,notification,ring,system,voicecall 1.25b
app.SetWifiEnabled(enable)
app.ShowDebug( p1 )
app.ShowKeyboard( ctrl ) ctrl must already have focus 1.29
app.ShowMenu( p1,p2 ) This Sample demonstrates how to show the menu
app.ShowPopup( text, options ) Display a message text for some seconds an the screen. Paramater options: “Short”, “Bottom”.
app.ShowPopup( "Hello World", "Short, Bottom");
app.ShowProgress( text ) Shows progress bar with optional text. Text could be “Loading…”.
app.ShowProgressBar( text, percent ) Shows progress bar window with a spinning animation and message text with percentage progress shown in percent parameter.
app.SimulateTouch( obj,x,y,dir ) This Sample shows how to use SimulateTouch
app.StartApp( file,options ) Starts DroidScript application from script in file. File is the fullpath to the app. Parameter options is optional.
app.StartDebugServer()
app.StartService(packageName,className)
app.StopApp( file ) Stops DroidScript application from script in file. File is the fullpath to the app.
app.StopService()
app.TextToSpeech( text, pitch, speed ) The TextToSpeech method uses Android's speech engine to speek out loud the given text. You can specify the pitch and speed of the output with decimal values where a value of 1.0 is used for normal pitch or speed.
app.ToBack() Sample how to send your App to the Background
app.Try( p1,p2,p3 )
app.UpdateProgressBar( percent ) Updates progress in a progress bar window shown by ShowProgressBar method by percent parameter.
app.Vibrate( pattern ) The Vibrate method vibrates the phone or tablet with a given pattern. The vibrate pattern is passed in as a text parameter with comma separated integer values given in milliseconds with this format: pause, vibrate, pause, vibrate.
app.Wait( secs ) This function is not recommended
app.WriteFile( file,text,mode ) Writes file, where it is the fullpath of the file a text from parameter text. Parameter mode options can be “Append” or “Ascii”.
built_in/app.txt · Last modified: 2015/12/14 06:54 (external edit)