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

This is an old revision of the document!


The app object

Methods

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

Method Description/Sample
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 )
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.CreateGLView( width,height,options )
app.CreateImage( file,width,height,options,w,h )
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 )
app.CreateService( name,callback )
app.CreateShortcut( p1,p2,p3 )
app.CreateSmartWatch( p1 )
app.CreateSMS()
app.CreateSpeechRec( options )
app.CreateSpinner( list,width,height,options )
app.CreateSynth( p1 )
app.CreateSysProc()
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 )
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 file. File 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.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.GetAppName() Returns the name of your App.
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 free space in gigabytes. Parameter option can be: “internal” or “external”.
app.GetInternalFolder()
app.GetIPAddress() Returns the IP Address of your mobile.
app.GetJoystickName( id )
app.GetJoystickState( id,key )
app.GetLanguage()
app.GetLanguageCode()
app.GetLastButton()
app.GetLastCheckBox()
app.GetLastImage()
app.GetLastToggle()
app.GetMacAddress()
app.GetMetadata( file,keys )
app.GetModel() Sample Get Device Infos
app.GetName()
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.GetPath()
app.GetPrivateFolder( name )
app.GetRotation()
app.GetScreenDensity() Sample Get Device Infos
app.GetScreenHeight() Returns the Height of your mobile
Sample Get Device Infos
app.GetScreenWidth() Returns the Width of your mobile
Sample Get Device Infos
app.GetSharedFiles()
app.GetSharedText( p1 )
app.GetTop()
app.GetUser()
app.GetVersion()
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.IsBluetoothOn() Checks if Bluetooth is on.
app.IsFolder( folder ) Checks if folder is a file or folder.
app.IsNewVersion()
app.IsPro()
app.IsScreenOn()
app.IsTablet() Check if the device is a tablet. Returns true or false. Sample Get Device Infos
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.
app.ListFolder( "/sdcard/mp3", ".mp3", 50);
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.SendMail( address,subject,body,attach ) Send the email message via built in email app.
(Leave 4th parameter out if attachment is not required).
app.SetAlarm( type,id,callback,time,interval )
app.SetAutoBoot(TrueFalse) Calling app.SetAutoBoot( true ) method will cause DroidScript be started automatically when your phone 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.SetClipboardText( text ) Copy the Text to your Clipboard
app.SetData( p1,p2 )
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( p1 )
app.SetOnError( callback )
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.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" ); 
app.SetSharedApp( p1 )
app.SetTitle( p1 ) This method is obsolete
app.ShowDebug( p1 )
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()
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 )
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.1427397334.txt.gz · Last modified: 2015/03/27 03:15 (external edit)