=====The app object===== ====Methods==== The following table lists the methods available from the app object. ^ Method ^ Description/Sample ^ added ^ | app._Extract( p1 ) | | | | [[built_in:add_layout|app.AddLayout( layout )]] | Adds a **layout** to the App. | | | [[built_in:alert|app.Alert( text, title )]] | Shows a message on the screen with an OK button and text given in **text** parameter with optional **title**. | | | [[built_in:broadcast|app.Broadcast( p1,p2 )]] | | | | [[built_in:call|app.Call( number )]] | Makes phone call to a **number**. | | | [[built_in:clear_data|app.ClearData(file)]] | clears app.SaveText/SaveNumber..etc | 1.29 | | [[built_in:copy_file|app.CopyFile( src, dest )]] | Copy a file **src** from the app to the **dest** folder on the SD-card. | | | [[built_in:copy_folder|app.CopyFolder( src,dest,overwrite )]] | | | | [[built_in:check_license|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. | | | [[built_in:audiorecorder|app.CreateAudioRecorder()]] | | | | [[built_in:bluetoothlist|app.CreateBluetoothList( p1 )]] | | | | [[built_in:bluetoothserial|app.CreateBluetoothSerial( mode )]] | | | | [[built_in:buttons|app.CreateButton( text, width, height, options )]] | | | | [[built_in:cameraview|app.CreateCameraView( width,height,options )]] | | | | [[built_in:checkboxes|app.CreateCheckBox( text, width, height, options )]] | | | | [[built_in:crypt|app.CreateCrypt( options )]] | | | | [[built_in:debug|app.CreateDebug()]] | | | | [[built_in:dialog|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. | | | [[built_in:downloader|app.CreateDownloader()]] | | | | [[built_in:email|app.CreateEmail( ownmail,mailpass )]] | | | | [[built_in:create_file|app.CreateFile(file,mode)]] | | 1.23b | | [[built_in:glview|app.CreateGLView( width,height,options )]] | | | | [[built_in:images|app.CreateImage( file,width,height,options,w,h )]] | new “Alias” option since V1.23b | | | [[built_in:ioio|app.CreateIOIO( p1 )]] | | | | [[built_in:layouts|app.CreateLayout( type,options )]] | | | | [[built_in:lists|app.CreateList( list,width,height,options )]] | list is a comma seperated list | | | [[built_in:listdialog|app.CreateListDialog( headertext,list,p3 )]] | | | | [[built_in:listview|app.CreateListView( list,title,options )]] | | | | [[built_in:locator|app.CreateLocator( type,p2 )]] | | | | [[built_in:mediaplayer|app.CreateMediaPlayer()]] | | | | [[built_in:mediastore|app.CreateMediaStore()]] | | | | [[built_in:netclient|app.CreateNetClient( p1 )]] | | | | [[built_in:notification|app.CreateNotification( options )]] | | | | [[built_in:nxt|app.CreateNxt()]] | Creates the NXT object is used to manage the connection between your Android phone/tablet and the Lego Mindstorms NXT brick. | | | [[built_in:nxtremote|app.CreateNxtRemote()]] | Internal NXTRemote object. Use NXT object from [[built_in:nxt|app.CreateNXT()]] | | | [[built_in:object|app.CreateObject( name )]] | | | | [[built_in:playstore|app.CreatePlayStore()]] | | | | [[built_in:scroller|app.CreateScroller( width,height,p3 )]] | | | | [[built_in:seekbars|app.CreateSeekBar( width,height,p3 )]] | | | | [[built_in:sensors|app.CreateSensor( type,options )]] | types: Accelerometer, MagneticField, Orientation, Light, Proximity, Temperature, GameRotation, GeomagneticRotation, Gravity, Gyroscope, HeartRate, Acceleration, Pressure, Humidity, RotationMotion, StepCounter, StepDetector | | | [[built_in:service|app.CreateService( packageName, classname, callback, options )]] | | | | [[built_in:shortcut|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 | | | [[built_in:smartwatch|app.CreateSmartWatch( p1 )]] | | | | [[built_in:sms|app.CreateSMS()]] | | | | [[built_in:speechrecognition|app.CreateSpeechRec( options )]] | option 'NoBeep' (only works on phones at moment). | | | [[built_in:spinner|app.CreateSpinner( list,width,height,options )]] | | | | [[built_in:synth|app.CreateSynth( p1 )]] | | | | [[built_in:sys_proc|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. | | | [[built_in:tabs|app.CreateTabs( list,width,height,options )]] | | | | [[built_in:text|app.CreateText( text,width,height,options )]] | | | | [[built_in:textedit|app.CreateTextEdit( text,width,height,options )]] | | | | [[built_in:togglebuttons|app.CreateToggle( text,width,height,options )]] | | | | [[built_in:usbserial|app.CreateUSBSerial( baudRate,dataBits,stopBits,parity )]] | | | | [[built_in:videoview|app.CreateVideoView( width,height,options )]] | | | | [[built_in:webserver|app.CreateWebServer( p1,p2 )]] | new “Reflect” option since V1.23b | | | [[built_in:webview|app.CreateWebView( width,height,options,zoom )]] | | | | [[built_in:yesnodialog|app.CreateYesNoDialog( text )]] | | | | [[built_in:zip|app.CreateZipUtil( mode )]] | | | | [[built_in:debug|app.Debug( text )]] | Sends **text** info to the Debug tab and debug your app. | | | [[built_in:delete_database|app.DeleteDatabase(name)]] | | | | [[built_in:delete_file|app.DeleteFile( file )]] | Deletes a **file**. The **file** parameter needs the fullpath.app.DeleteFile( "/sdcard/wftest.txt" ); | | | [[built_in:delete_folder|app.DeleteFolder( folder )]] | app.DeleteFolder( "/sdcard/Temp" ); | | | [[built_in:destroy_layout|app.DestroyLayout( layout )]] | | | | [[app_methods:enablebackkey|app.EnableBackKey( true/false )]] | Sets if your App will exit, if you press the Back-Key.app.EnableBackKey( false ); | | | [[built_in:disable_keys|app.DisableKeys(keyList)]] | disables normal function of given keys | 1.29 | | [[built_in:execute|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_methods:enablebackkey|app.Exit( p1 )]] | Stops your App. | | | [[built_in:extract_assets|app.ExtractAssets( src,dest,overwrite )]] | Copy content from one folder to another. If **overwrite** = true, then existing files in destination folder will be overwritten. | | | [[built_in:file_Exists|app.FileExists( file )]] | Checks if a **file** exist and returns "true" or "false". | | | [[built_in:folder_exists|app.FolderExists( folder )]] | Checks if a **folder** exist and returns "true" or "false". | | | [[built_in:get_accounts|app.GetAccounts()]] | | 1.25b | | [[built_in:get_app_name|app.GetAppName()]] | Returns the name of your App. | | | [[built_in:get_battery_level|app.GetBatteryLevel()]] | | 1.29 | | [[built_in:get_app_path|app.GetAppPath()]] | Returns the path of your App. | | | [[built_in:get_built_num|app.GetBuildNum()]] | Returns the version number of the Android operating system currently running. | | | [[built_in:get_clipboard_text|app.GetClipboardText()]] | Returns the Text, which is copied to your Clipboard. | | | [[built_in:get_country|app.GetCountry()]] | | | | [[built_in:get_country_code|app.GetCountryCode()]] | | | | [[built_in:get_data|app.GetData( p1 )]] | | | | [[built_in:get_database_folder|app.GetDatabaseFolder()]] | | | | [[app_methods:setorientation|app.GetDefaultOrientation()]] | Returns the "normal" Orientation of the device. | | | [[built_in:get_device_id|app.GetDeviceId()]] | | | | [[built_in:get_display_height|app.GetDisplayHeight()]] | Returns your Display Height.[[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:get_display_width|app.GetDisplayWidth()]] | Returns your Display Width\\ [[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:get_ds_version|app.GetDSVersion()]] | Returns the currently running version of DroidScript. | | | [[built_in:get_env|app.GetEnv()]] | | | | [[built_in:get_external_folder|app.GetExternalFolder()]] | Returns the path to the External sd card. | | | [[built_in:get_file_date|app.GetFileDate( file )]] | Returns the date of a **file** (file needs the full path). | | | [[built_in:get_file_size|app.GetFileSize( file )]] | Returns the size of a **file** in bytes (file needs the full path). | | | [[built_in:get_free_space|app.GetFreeSpace( option )]] | Returns the free space in gigabytes. Parameter **option** can be: "internal" or "external". | | | [[built_in:get_internal_folder|app.GetInternalFolder()]] | | | | [[built_in:get_ip_address|app.GetIPAddress()]] | Returns the IP Address of your device. | | | [[built_in:get_joystick_name|app.GetJoystickName( id )]] | | | | [[built_in:get_joystick_state|app.GetJoystickState( id,key )]] | | | | [[built_in:get_language|app.GetLanguage()]] | | | | [[built_in:get_language_code|app.GetLanguageCode()]] | | | | [[built_in:get_last_button|app.GetLastButton()]] | | | | [[built_in:get_last_checkbox|app.GetLastCheckBox()]] | | | | [[built_in:get_last_image|app.GetLastImage()]] | | | | [[built_in:get_last_toggle|app.GetLastToggle()]] | | | | [[built_in:get_mac_address|app.GetMacAddress()]] | | | | [[built_in:get_media_file|app.GetMediaFile(“MyApp”,“.png”)]] | | 1.23b | | [[built_in:get_metadata|app.GetMetadata( file,keys )]] | | | | [[built_in:get_model|app.GetModel()]] | [[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:get_name|app.GetName()]] | | | | [[built_in:get_notify_id|app.GetNotifyId()]] | gets id of in-comming notification | 1.29 | | [[built_in:get_objects|app.GetObjects()]] | Returns all Objects of your App | | | [[built_in:get_options|app.GetOptions()]] | | | | [[app_methods:setorientation|app.GetOrientation()]] | Returns the current orientation of the device | | | [[built_in:get_os_version|app.GetOSVersion()]] | Returns the version number of the Android operating system currently running.[[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:get_package_name|app.GetPackageName()]] | | 1.23b | | [[built_in:get_path|app.GetPath()]] | | | | [[built_in:get_private_folder|app.GetPrivateFolder( name )]] | | | | [[built_in:get_ringer_mode|app.GetRingerMode()]] | | | | [[built_in:get_rotation|app.GetRotation()]] | | | | [[built_in:get_running_apps|app.GetRunningApps()]] | | 1.29 | | [[built_in:get_running_services|app.GetRunningServices()]] | | 1.29 | | [[built_in:get_screen_density|app.GetScreenDensity()]] | [[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:get_screen_height|app.GetScreenHeight()]] | Returns the Height of your device\\ [[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:get_screen_width|app.GetScreenWidth()]] | Returns the Width of your device\\ [[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:get_shared_files|app.GetSharedFiles()]] | | | | [[built_in:get_shared_text|app.GetSharedText( p1 )]] | | | | [[built_in:get_special_folder|app.GetSpecialFolder( name )]] | 'DCIM','Pictures','Movies','Downloads' etc | 1.29 | | [[built_in:get_top|app.GetTop()]] | | | | [[built_in:get_user|app.GetUser()]] | | | | [[built_in:get_version|app.GetVersion()]] | Returns the version of the APK the code is running in. If not a built APK, returns the DroidScript version | | | [[built_in:get_volume|app.GetVolume(stream)]] | streams: alarm,dtmf,music,notification,ring,system,voicecall | 1.25b | | [[built_in:go_to_sleep|app.GoToSleep()]] | | | | [[built_in:hide_keyboard|app.HideKeyboard( p1 )]] | | | | [[built_in:hide_progress|app.HideProgress()]] | Hides progress bar window shown by [[built_in:show_progress|ShowProgress]] method. | | | [[built_in:hide_progressbar|app.HideProgressBar()]] | Hides progress bar window shown by [[built_in:show_progress_bar|ShowProgressBar]] method. | | | [[built_in:is_bluetooth_enabled|app.IsBluetoothEnabled()]] | | | | [[built_in:is_bluetooth_on|app.IsBluetoothOn()]] | Checks if Bluetooth is on. | | | [[built_in:is_chrome|app.IsChrome()]] | detects running in arc welded chrome | 1.23b | | [[built_in:is_folder|app.IsFolder( folder )]] | Checks if **folder** is a file or folder. | | | [[built_in:is_keyboard_shown|app.IsKeyboardShown()]] | | 1.29 | | [[built_in:is_new_version|app.IsNewVersion()]] | | | | [[built_in:is_pro|app.IsPro()]] | | | | [[built_in:is_screen_on|app.IsScreenOn()]] | | | | [[built_in:is_tablet|app.IsTablet()]] | Check if the device is a tablet. Returns true or false. [[sample_code:get_device_specs|Sample Get Device Infos]] | | | [[built_in:is_wifi_enabled|app.IsWifiEnabled()]] | | | | [[built_in:kill_app|app.KillApp( file )]] | Delete the file\\ (file needs the fullpath) | | | [[built_in:list_folder|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"** | | | [[built_in:load_boolean|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. | | | [[built_in:load_number|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. | | | [[built_in:load_plugin|app.LoadPlugin( url )]] | | | | [[built_in:load_script|app.LoadScript( url, callback )]] | | | | [[built_in:load_text|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. | | | [[built_in:make_folder|app.MakeFolder( fldr )]] | | | | [[built_in:odroid|app.Odroid(p1,p2,p3)]] | | | | [[built_in:Database|app.OpenDatabase(name)]] | | | | [[built_in:open_file|app.OpenFile( file,type,choose )]] | | | | [[built_in:open_url|app.OpenUrl( url )]] | | | | [[built_in:prevent_screen_lock|app.PreventScreenLock( truefalse )]] | | | | [[built_in:prevent_wifi_sleep|app.PreventWifiSleep( p1 )]] | | | | [[built_in:read_file|app.ReadFile( file, options )]] | | | | [[built_in:remove_layout|app.RemoveLayout( layout )]] | | | | [[built_in:rename_file|app.RenameFile( filename,newname )]] | | | | [[built_in:rename_folder|app.RenameFolder( foldername,newfoldername )]] | | | | [[built_in:save_boolean|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. | | | [[built_in:save_number|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. | | | [[built_in:save_text|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. | | | [[built_in:send_file|app.SendFile(file,subject,text)]] | sends files to other Apps, user chooses | 1.29 | | [[built_in:send_intent|app.SendIntent( packageName, className, action, category, data, type, extras, options )]] | | 1.23b | | [[built_in:send_mail|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). | | | [[built_in:send_message|app.SendMessage(msg)]] | | 1.29 | | [[built_in:set_alarm|app.SetAlarm( type,id,callback,time,interval )]] | | | | [[built_in:set_auto_boot|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. | | | [[built_in:set_auto_wifi|app.SetAutoWifi(TrueFalse)]] | The app.SetAutoWifi( true ) method will cause DroidScript to turn on the WiFi editor automatically | | | [[built_in:set_bluetooth_enabled|app.SetBluetoothEnabled(enable)]] | | | | [[built_in:set_clipboard_text|app.SetClipboardText( text )]] | Copy the Text to your Clipboard | | | [[built_in:set_data|app.SetData( name,value )]] | | | | [[built_in:set_debug_enabled|app.SetDebugEnabled( enable )]] | Switch off debugging for max speed.\\ (keep this on during developement)\\ app.SetDebugEnabled( false ); | | | [[built_in:set_joystick_options|app.SetJoystickOptions( options )]] | | | | [[built_in:set_menu|app.SetMenu( list,p2 )]] | Parameter **list** is a comma separated list with the menupoints\\ [[tips_tricks:menubutton|This Sample demonstrates how to set a menu]] | | | [[built_in:set_on_broadcast|app.SetOnBroadcast( callback )]] | | | | [[built_in:set_on_error|app.SetOnError( callback )]] | | | | [[built_in:set_on_key|app.SetOnKey(callback)]] | reports key changes, including volume key | 1.29 | | [[built_in:set_options|app.SetOptions(options)]] | | | | [[app_methods:setorientation|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. | | | [[built_in:set_ringer_mode|app.SetRingerMode( mode )]] | use **Normal**, **Vibrate** or **Silent** to set the mode | | | [[built_in:set_screen_brightness|app.SetScreenBrightness( level )]] | The **SetScreenBrightness** method sets the screen brightness for this App with a decimal value **level** between 0 and 1. | | | [[built_in:set_screen_mode|app.SetScreenMode( mode )]] | Set full screen mode.app.SetScreenMode( "Full" ); new "Game" mode since V1.23b | | | [[built_in:set_shared_app|app.SetSharedApp( p1 )]] | | | | app.SetTitle( p1 ) | This method is obsolete | | | [[built_in:set_volume|app.SetVolume(stream,level)]] | streams: alarm,dtmf,music,notification,ring,system,voicecall | 1.25b | | [[built_in:set_wifi_enabled|app.SetWifiEnabled(enable)]] | | | | [[built_in:show_debug|app.ShowDebug( p1 )]] | | | | [[built_in:show_keyboard|app.ShowKeyboard( ctrl )]] | ctrl must already have focus | 1.29 | | [[built_in:show_menu|app.ShowMenu( p1,p2 )]] | [[tips_tricks:menubutton|This Sample demonstrates how to show the menu]] | | | [[built_in:show_popup|app.ShowPopup( text, options )]] | Display a message **text** for some seconds an the screen. Paramater **options**: "Short", "Bottom".app.ShowPopup( "Hello World", "Short, Bottom"); | | | [[built_in:show_progress|app.ShowProgress( text )]] | Shows progress bar with optional **text**. Text could be "Loading...". | | | [[built_in:show_progress_bar|app.ShowProgressBar( text, percent )]] | Shows progress bar window with a spinning animation and message **text** with percentage progress shown in **percent** parameter. | | | [[built_in:simulate_touch|app.SimulateTouch( obj,x,y,dir )]] | [[sample_code:simulate_touch|This Sample shows how to use SimulateTouch]] | | | [[built_in:start_app|app.StartApp( file,options )]] | Starts DroidScript application from script in **file**. File is the fullpath to the app. Parameter **options** is optional. | | | [[built_in:start_debug_server|app.StartDebugServer()]] | | | | [[built_in:start_service|app.StartService(packageName,className)]] | | | | [[built_in:stop_app|app.StopApp( file )]] | Stops DroidScript application from script in **file**. File is the fullpath to the app. | | | [[built_in:stop_service|app.StopService()]] | | | | [[built_in:text_to_speech|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. | | | [[built_in:to_back|app.ToBack()]] | [[sample_code:app_toback|Sample how to send your App to the Background]] | | | [[built_in:try|app.Try( p1,p2,p3 )]] | | | | [[built_in:update_progress_bar|app.UpdateProgressBar( percent )]] | Updates progress in a progress bar window shown by [[built_in:show_progress_bar|ShowProgressBar]] method by **percent** parameter. | | | [[built_in:vibrate|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. | | | [[built_in:wait|app.Wait( secs )]] | This function is not recommended | | | [[built_in:write_file|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". | |