Open Forum > What's New
ScriptBasic for Android
Support:
Here is an example of a request / response call to the SL4A RPC server. This is opening a SB socket and sending a JSON packet to the RPC scripting server. (see attached screenshot)
The Androids API (scripting version) is fairly extensive. I would be willing to help build this interface if others contribute. I'll post a few high level functions to get the ball rolling and see what happens. My initial goal was to create a proof of concept and see if others saw promise or not. If there is no interest by others then I'll return to my IUP project and revisit this again at later time.
Support:
I'm playing around with a JSON response parser that creates a SB associative array. This is my first stab at it and may find a better way.
--- Code: ---r = """{"error":null,"id":1,"result":"gsm"}"""
r = MID(r,2)
r = LEFT(r,LEN(r) - 1)
r = REPLACE(r, "\"", "")
SPLITA r BY "," TO t
FOR x = 0 to UBOUND(t)
a{LEFT(t[x],INSTR(t[x],":")-1)} = MID(t[x],INSTR(t[x],":")+1)
NEXT
PRINT a{"error"},"\n"
PRINT a{"id"},"\n"
PRINT a{"result"},"\n"
--- End code ---
jrs@laptop:~/sb/test$ scriba json_in.sb
null
1
gsm
jrs@laptop:~/sb/test$
Support:
The following Facade's are available for ownership. Please let us know which Facade you will be working on. I will be doing random functions to help with areas that aren't well documented.
Android SL4A API
[*]ActivityResultFacade
[*]AndroidFacade
[*]ApplicationManagerFacade
[*]BatteryManagerFacade
[*]BluetoothFacade
[*]CameraFacade
[*]CommonIntentsFacade
[*]ContactsFacade
[*]EventFacade
[*]LocationFacade
[*]MediaPlayerFacade
[*]MediaRecorderFacade
[*]PhoneFacade
[*]PreferencesFacade
[*]SensorManagerFacade
[*]SettingsFacade
[*]SignalStrengthFacade
[*]SmsFacade
[*]SpeechRecognitionFacade
[*]TextToSpeechFacade
[*]ToneGeneratorFacade
[*]UiFacade
[*]WakeLockFacade
[*]WebCamFacade
[*]WifiFacade
[/list]
Support:
I started building an Android SL4A module to kick things off. Don't wait too long or your favorite Facade may be taken. ;)
--- Code: ---' Android SL4A Interface
'
' ScriptBasic Open Source Project
'
' Contributors:
' John Spikowski (JRS)
'
' Change Log:
' 20120513 - Initial module created
MODULE DVM
OPEN "localhost:9999" FOR SOCKET AS #1
id = 1
FUNCTION JSON2SB(json_response)
LOCAL r,t,x,a
r = MID(json_response,2)
r = LEFT(r,LEN(r) - 1)
r = REPLACE(r, "\"", "")
SPLITA r BY "," TO t
FOR x = 0 to UBOUND(t)
a{LEFT(t[x],INSTR(t[x],":")-1)} = MID(t[x],INSTR(t[x],":")+1)
NEXT
JSON2SB = a
END FUNCTION
'**************
' PhoneFacade *
'**************
FUNCTION getPhoneType()
LOCAL r, a
PRINT #1,"""{"id":""" & id & ""","method":"getPhoneType","params":[]}\n"""
LINE INPUT #1, r
a = JSON2SB(r)
IF a{"error") <> "null" THEN
getPhoneType = undef
ELSE
getPhoneType = a{"result"}
END IF
id += 1
END FUNCTION
END MODULE
--- End code ---
Untested at time of posting.
kryton9:
I have lots of catching up to do John, you are moving right along. That is great.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version