app - Основной объект для работы, создания новых элементов¶
- class
droidscript.
app
¶ Глобальный объект, предоставляющий API для работы с Android устройством
-
_Extract
(p1)¶
-
BluetoothList
(p1)¶ Возвращает
BluetoothList()
-
BluetoothSerial
(mode)¶
-
Broadcast
(p1, p2)¶
-
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
-
CreateAudoRecorder
()¶ Возвращает
AudioRecorder()
, устройство для записи звуковrecorder = app.CreateAudoRecorder()
-
CreateBluetoothSerial
()¶
-
CreateDebug
(debug text)¶
-
CreateDownloader
()¶ Downloader()
-
CreateImage
(file, width, height, options, bitmapx, bitmapy)¶ Возвращает
Image()
- options
async - FontAwesome Use this option to write icons as Text on your image
Resize - The Resize option internally scales down the original image to the display size, so it uses up less memory than the full size image (useful if you are lots of thumbnail images)
ScaleCenter - you can use the option to keep the image at it’s original size and centered within the Image object
// картинка из assets img = app.CreateImage('Img/myimage.png'); // пустая картинка img = app.CreateImage(null, 0.8, 0.8); // с граниченным bitmap, 480-800 canvas = app.CreateImage( null, 1.0, 1.0, "fix", 480, 800 );
-
CreateLocator
(type, p2)¶ Возвращает
Locator()
“GPS” “Network” “GPS,Network”
loc = app.CreateLocator('GPS,Network');
-
CreateMediaPleer
()¶ Возвращает
MediaPlerr()
, проигрывать музфкальных файловplayer = app.CreateMediaPleer()
-
CreateMediaStore
()¶ Возвращает
MediaStore()
store = app.CreateMediaStore()
-
CreateNetClient
(type)¶ Возвращает
NetClient()
net = app.CreateNetClient('TCP'); net = app.CreateNetClient('TCP,Raw'); net = app.CreateNetClient('UDP');
-
CreateNxt
()¶ Creates the NXT object is used to manage the connection between your Android phone/tablet and the Lego Mindstorms NXT brick
-
CreateNxtRemote
()¶ Internal NXTRemote object. Use NXT object from app.CreateNXT()
-
CreateObject
(name)¶
-
CreatePlayStore
()¶ Возвращает
PlayStore()
playstore = app.CreatePlayStore()
-
CreateSensor
(type, options)¶ Возвращает
Sensor()
type
Accelerometer -
MagneticField -
Light -
Orientation -
Proximity -
Temperature
GameRotation
GeomagneticRotation
Gravity
Gyroscope
HeartRate
Acceleration
Pressure
Humidity
RotationMotion
StepCounter
StepDetector
options
Fast -
Fastest -
Medium -
Slow -
sns = app.CreateSensor( "Accelerometer" ); sns.SetOnChange(function(x, y, z, time){}); sns.Start(); sns = app.CreateSensor( "Orientation" ); sns.SetOnChange(function(azimuth, pitch, roll, time){}); sns.Start(); sns = app.CreateSensor( "Light" ); sns.SetOnChange(function(lux){}); sns.Start();
-
CreateSmartWatch
(p1)¶
-
CreateSpeechRec
(options)¶ Возвращает
SpeechRec()
, звукозаписьspeech = app.CreateSpeechRec(); speech = app.CreateSpeechRec('NoBeep');
-
CreateSynth
(p1)¶ Возвращает
Synth()
, синтезаторsynth = app.CreateSynth('VCF'); synth = app.CreateSynth('Signal');
-
CreateUSBSerial
(baudRate, dataBits, stopBits, parity)¶
-
CreateWebServer
(port, options)¶ Возвращает
WebServer()
webserver = CreateWebServer(8080, 'Upload,ListDir'); webserver = CreateWebServer(8080, 'Reflect');
-
Debug
(text)¶ -
DisableKeys
(keyList)¶
-
EnableBackKey
(enable)¶ Включает/выключает стандартное поведение кнопки назад. Если стандартное поведение выключено, будет вызываться глобальный метод
OnBack()
function OnStart(){ app.EnableBackKey(false); } function OnBack(){ ... }
-
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' )" ); app.Execute( "Alert( \"Hi\" )" );
-
Exit
(p1)¶ Завершает выполнение программы
app.Exit()
-
GetAccounts
()¶
-
GetAppName
()¶ Возвращает имя приложения
name = app.GetAppName()
-
GetAppPath
()¶ Возвращает путь папки приложения
app_path = app.GetAppPath()
-
GetBatteryLevel
()¶
-
GetBuildNum
()¶
-
GetClipboardText
()¶ Возвращает текст буфера обмена, для установки используйте
SetClipboardText()
text = app.GetClipboardText()
-
GetCountry
()¶
-
GetCountryCode
()¶
-
GetData
(p1)¶
-
GetDatabaseFolder
()¶
-
GetDefaultOrientation
()¶ Возвращает стандртную ориентацию экрана: Portrait или Landscape,
GetOrientation()
,SetOrientation()
orinet = app.GetDefaultOrientation()
-
GetDeviceId
()¶
-
GetDisplayHeight
()¶ Возвращает доступную высоту экрана в пикселях для вашего приложения, исключается верхняя и нижняя информационные поля.
height = app.GetDisplayHeight()
-
GetDisplayWidth
()¶ Возвращает доступную ширину экрана в пикселях для вашего приложения, исключается верхняя и нижняя информационные поля.
width = app.GetDisplayWidth()
-
GetDSVersion
()¶
-
GetEnv
()¶
-
GetIntent
()¶ intent = app.GetIntent() /* * intent.action * intent.type * intent.data * intent.extras */
-
GetIPAddress
()¶ Возвращает ip адрес вашего устройства, если включен WiFi
ip = app.GetIPAddress()
-
GetJoystickName
(joyNum)¶ Возвращает имя джойстика, подключенного к устройству через OTG
joy_name = app.GetJoystickName(0)
-
GetJoystickState
(joyNum, keyNum)¶ Возвращает состояние кнопки указанного джойстика, подключенного к устройству через OTG.
1 - кнопка нажата, 0 - кнопка не нажата
-1,0 … 1,0 - для axis устройств. Например если для оси-х вернется -1,0 то значит влево, 1,0 -> вправо.
axis - кнопки, могут быть от axis-0 до axis-9
Кнопка
Описание
“Up”
DPad Up
“Down”
DPad Down
“Left”
DPad Left
“Right”
DPad Right
“Center”
DPad Center
“X”, “Y”, “Z”
X, Y and Z Buttons
“A”, “B”, “C”
A, B and C Buttons
“Start”
Start Button
“ThumbLeft”
Left Thumb Buttons
“ThumbRight”
Right Thumb Buttons
abtn = app.GetJoystickState( 0, "A" ); bbtn = app.GetJoystickState( 0, "B" ); xaxis = app.GetJoystickState( 0, "axis-0" ); yaxis = app.GetJoystickState( 0, "axis-1" );
-
GetLanguage
()¶
-
GetLanguageCode
()¶
-
GetMacAddress
()¶ Возвращает MAC адрес WiFi устройства
mac = app.GetMacAddress()
-
GetMediaFile
(“MyApp”, “.png”)¶
-
GetMetadata
(file, keys)¶
-
GetModel
()¶ Возвращает идентификатор модели устройства
model = app.GetModel()
-
GetName
()¶
-
GetObjects
()¶ Returns all Objects of your App
-
GetOptions
()¶
-
GetOrientation
()¶ Возвращает текущую ориентацию экрана: Portrait или Landscape,
GetDefaultOrientation()
,SetOrientation()
orient = app.GetOrientation()
-
GetOSVersion
()¶ Возвращает версию операционной системы
Кодовое имя
Версия
API level
(no code name)
1.0 API
level 1
(no code name)
1.1 API
level 2
Cupcake
1.5 API
level 3
Donut
1.6 API
level 4
Eclair
2.0 API
level 5
Eclair
2.0.1
API level 6
Eclair
2.1
API level 7
Froyo
2.2.x
API level 8
Gingerbread
2.3 - 2.3.2
API level 9
Gingerbread
2.3.3 - 2.3.7
API level 10
Honeycomb
3.0
API level 11
Honeycomb
3.1
API level 12
Honeycomb
3.2.x
API level 13
Ice Cream Sandwich
4.0.1 - 4.0.2
API level 14
Ice Cream Sandwich
4.0.3 - 4.0.4
API level 15
Jelly Bean
4.1.x
API level 16
Jelly Bean
4.2.x
API level 17
Jelly Bean
4.3.x
API level 18
KitKat
4.4 - 4.4.4
API level 19
version = app.GetOSVersion()
-
GetPackageName
()¶
-
GetPath
()¶
-
GetRingerMode
()¶
-
GetRotation
()¶ Возвращает текущий угол поворота устройства: 0, 90, 180, 270
rot = app.GetRotation()
-
GetRunningApps
()¶
-
GetRunningServices
()¶
-
GetScreenDensity
()¶ Возвращает плотность экрана устройства, dpi
dpi = app.GetScreenDensity()
-
GetScreenHeight
()¶ Возвращает высоту экрана устрйоства
dpi = app.GetScreenHeight()
-
GetScreenWidth
()¶ Возвращает ширину экрана устрйоства
dpi = app.GetScreenWidth()
-
GetTop
()¶
-
GetUser
()¶ Возвращает email адрес для главного пользователя
user = app.GetUser()
-
GetUser
()
-
GetVersion
()¶
-
GetVolume
(stream)¶ streams: alarm,dtmf,music,notification,ring,system,voicecall 1.25b
-
GoToSleep
()¶
-
HideKeyboard
(p1)¶
-
IsBluetoothEnabled
()¶
-
IsBluetoothOn
()¶ Возвращает булево, включен ли bluetooth
bthOn = app.IsBluetoothOn()
-
IsBluetoothOn() Checks if Bluetooth is on.
-
IsChrome() detects running in arc welded chrome 1.23b
-
IsFolder( folder ) Checks if folder is a file or folder.
-
IsKeyboardShown() 1.29
-
IsNewVersion
()¶
-
IsPro
()¶
-
IsScreenOn
()¶ Возвращает булево, включен ли экран
bthOn = app.IsScreenOn()
-
IsTablet
()¶ Возвращает булево, планшет ии смартфон
tablet = app.IsTablet();
-
IsWifiEnabled
()¶
-
KillApp
(file)¶
-
LoadPlugin
(url)¶
-
LoadScript
(url, callback)¶
-
Odroid
(p1, p2, p3)¶
-
OpenUrl
(url)¶ Открывает урл во внешенем web браузере
app.OpenUrl('http://google.com');
-
PreventScreenLock
(prevent)¶ Разрешает/запрещает блокировку экрана
app.PreventScreenLock(true);
-
PreventWifiSleep
(p1)¶
-
SendIntent
(packageName, className, action, category, uri, type, extras)¶ { var packageName = "com.google.android.gm"; var className = "com.google.android.gm.ComposeActivityGmail"; var action = "android.intent.action.VIEW"; var category = null; var uri = "myfriend@gmail.com"; var type = "message/rfc822"; var extras = [ {name:"android.intent.extra.EMAIL", type:"list", value:"fred@gmail.com"}, {name:"android.intent.extra.SUBJECT", type:"string", value:"My subject"}, {name:"android.intent.extra.TEXT", type:"string", value:"Hello!"} ]; extras = JSON.stringify( extras ); app.SendIntent( packageName, className, action, category, uri, type, extras ); }
-
SendMail
(address, subject, body, attachment)¶ Отправляет email сообщение из доступного email аккаунта
app.SendMail('ilnurgi87@gmail.com', 'MySubject', 'Hello', '/sdcard/file.txt')
-
SendMessage
(msg)¶
-
SetAlarm
(type, id, callback, time, interval)¶ Вызывает указанный обработчик, в указанное время, миллисекунды, даже если приложение свернуто.
В обработчик передается указанный идентификатор.
Все будильники выключается при перезагрузке
// устанавливает однократный будильник app.SetAlarm("Set", 1, function(id){}, 12345645675); // устанавливает периодический будильник app.SetAlarm("Repeat", 1, function(id){}, 12345645675б 10000); // выключает будильник app.SetAlarm("Cancel", 1);
-
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.
-
SetAutoWifi
(TrueFalse)¶ The app.SetAutoWifi( true ) method will cause DroidScript to turn on the WiFi editor automatically
-
SetBluetoothEnabled
(enable)¶
-
SetClipboardText
(text)¶ Вставляет в буфер обмена текст, для получения используйте
GetClipboardText()
app.SetClipboardText('my text');
-
SetData
(name, value)¶
-
SetDebugEnabled
(enabled)¶ Включает/выключает вывод в лог IDE отладочной информации
app.SetDebugEnabled(false);
-
SetJoystickOptions
(options)¶
-
SetOnBroadcast
(callback)¶
-
SetOnError
(callback)¶
-
SetOnKey(callback) reports key changes, including volume key 1.29
-
SetOptions
(options)¶
-
SetOrientation
(orientation, callback)¶ Устанавливает ориентацию экрана: Portrait или Landscape.
GetDefaultOrientation()
,GetOrientation()
app.SetOrientation("Landscape");
-
SetRingerMode
(mode)¶ use Normal, Vibrate or Silent to set the model
-
SetScreenBrightness
(brightness)¶ Устанавливает яркость экрана
app.SetScreenBrightness(0.25);
-
SetScreenMode
(mode)¶ Устанавливает тип экрана: Full, Game, Normal, Default
app.SetScreenMode('Full');
-
SetTitle( p1 ) This method is obsolete
-
SetVolume
(type, val)¶ Устанавливает уровень громкости
app.SetVolume('System', 1);
-
SetWifiEnabled
(enable)¶
-
ShowDebug
(p1)¶
-
ShowKeyboard( ctrl ) ctrl must already have focus 1.29
-
ShowMenu( p1,p2 ) This Sample demonstrates how to show the menu
-
SimulateTouch( obj,x,y,dir ) This Sample shows how to use SimulateTouch
-
StartApp( file,options ) Starts DroidScript application from script in file. File is the fullpath to the app. Parameter options is optional.
-
StartDebugServer
()¶
-
StartService
(packageName, className)¶
-
StopApp( file ) Stops DroidScript application from script in file. File is the fullpath to the app.
-
StopService
()¶
-
TextToSpeech
(text, pitch, speed, callback)¶ Произносит указанный тект
app.TextToSpeech('Hello World', 1.0, 1.0, function(){});
-
ToBack
()¶ Сврпачивает приложение
-
Try
(p1, p2, p3)¶
-
Vibrate
(pattern)¶ Включает вибрацию по указанному паттерну
app.Vibrate('0,100,30,100,50,300')
-
Wait
(secs)¶ is not recomendedee
-
-