Share your advanced knowledge/code with the community.
tj1010
 
Posts: 175
Joined: Wed May 27, 2015 1:36 pm

Android and IOS Front and Back Camera and WIFI Scanning

by tj1010 Wed Jul 05, 2017 4:27 pm

This is about 12 hours of reading Cordova and Cordova package docs and trial and error in chrome inspector since Import documentation was released two days ago. I got tired of it before I wrote filesystem enumerate, write, and read; those are only about 30 more lines.

From what I seen the only thing you probably can't do with Cordova plugins still is Google Maps stuff because SB is custon UI. Maybe with some inline JS to a webgadget to do markers, icons, links with Maps JS API.

Where to get more packages: https://cordova.apache.org/plugins/
Code: Select all
Import "cordova telemetry on" : EndImport
Import "cordova plugin add cordova-plugin-camera" : EndImport
Import "cordova plugin add wifiwizard" : EndImport

;Returns BASE64 data URL for bitmap
Procedure PictureOut(image.s)
  If Len(image)>0 : Debug image.s : EndIf
EndProcedure
PictureOut("")

;if you want to get a picture without user interaction you'll need one of the other camera plugins
Procedure.s GetPicture(camera.s)
  !if(v_camera=='FRONT') var direction=1;
  !if(v_camera=='BACK') var direction=0;
  !navigator.camera.getPicture(onSuccess, onFail,
  !{
  !    destinationType: Camera.DestinationType.DATA_URL,
  !    quality:100,
  !    cameraDirection:direction,
  !    sourceType: Camera.PictureSourceType.CAMERA,
  !    popoverOptions: new CameraPopoverOptions(300, 300, 100, 100, Camera.PopoverArrowDirection.ARROW_ANY)
  !});
  !function onSuccess(image){
  !f_pictureout(image);
  !}
  !function onFail(message){
  !f_pictureout(message);
  !}
EndProcedure

;WIFI JSON output callback
Procedure APOutput(nodes.s)
  If Len(nodes.s)>0 : Debug nodes.s : EndIf
EndProcedure
APOutput("")

;scan WIFI APs
;getScanResults might need to be in a timer
Procedure GetAccessPoints()
  !function iweufwhi(isenabled){
  !if(isenabled===true){
  !WifiWizard.startScan(function(){},function(){});
  !WifiWizard.getScanResults({},function(networks){f_apoutput(JSON.stringify(networks));},function(networks){});
  !}
  !}
  !WifiWizard.isWifiEnabled(function(enabled){iweufwhi(enabled);},function(){});
EndProcedure

GetPicture("FRONT")
GetAccessPoints()
Last edited by tj1010 on Wed Jul 05, 2017 5:28 pm, edited 1 time in total.
User avatar
Peter
 
Posts: 447
Joined: Mon Feb 24, 2014 10:17 pm
Location: 127.0.0.1

Re: Android and IOS Front and Back Camera and WIFI Scanning

by Peter Wed Jul 05, 2017 5:25 pm

Interesting, thanks!

Too bad that it is still not possible to create Android-Apps with Linux. :(

Greetings ... Peter
tj1010
 
Posts: 175
Joined: Wed May 27, 2015 1:36 pm

Re: Android and IOS Front and Back Camera and WIFI Scanning

by tj1010 Wed Jul 05, 2017 5:32 pm

Peter wrote:Interesting, thanks!

Too bad that it is still not possible to create Android-Apps with Linux. :(

Greetings ... Peter


VM and CLI via a basic server written in PB. I do it with an xubuntu VM in windows for PB Debian builds. It's easier than the IDE menus.
firace
 
Posts: 11
Joined: Tue Jan 02, 2018 6:59 pm

Re: Android and IOS Front and Back Camera and WIFI Scanning

by firace Mon Jan 15, 2018 7:35 pm

@tj1010: Does not work for me. I'm getting the below errors. Should I manually download/install these plugins first? If so, how?

Code: Select all
Uncaught TypeError: Cannot read property 'getPicture' of undefined
    at f_getpicture (spiderbasic.js:268)
    at SpiderLaunch (spiderbasic.js:311)
    at SpiderMain (main.js:24)
    at main.js:41
    at fa (dojo.js:19)
    at dojo.js:20
    at ga (dojo.js:20)
    at da (dojo.js:20)
    at s (dojo.js:22)
    at HTMLScriptElement.<anonymous> (dojo.js:27)


Thanks!
tj1010
 
Posts: 175
Joined: Wed May 27, 2015 1:36 pm

Re: Android and IOS Front and Back Camera and WIFI Scanning

by tj1010 Fri Jan 19, 2018 2:34 pm

Are you running it on Android or IOS? It won't work on x86 browsers.

If you're running it on mobile platforms then it looks like a bug in recent SB linker-chain. It was tested two versions ago. I'm still working around the adb bug in SB where I have to manually call adb with the output apk, and don't get mutch time to test things. You shouldn't need to download anything though; I never did.
firace
 
Posts: 11
Joined: Tue Jan 02, 2018 6:59 pm

Re: Android and IOS Front and Back Camera and WIFI Scanning

by firace Fri Jan 19, 2018 4:08 pm

tj1010 wrote:Are you running it on Android or IOS? It won't work on x86 browsers.

If you're running it on mobile platforms then it looks like a bug in recent SB linker-chain. It was tested two versions ago. I'm still working around the adb bug in SB where I have to manually call adb with the output apk, and don't get mutch time to test things. You shouldn't need to download anything though; I never did.


Ah, that was it! It works fine on my mobile indeed. Thanks.

I was running it on my desktop browser and had so many errors that I did not even think of trying it on my mobile... :oops:

About your adb issue, not sure what the cause is. For me the toolchain is working just fine (SB 2.20 x86 + JDK 1.8.0_151 on Win 10 x64)

For a quick fix, perhaps you could try to uninstall/reinstall? IIRC this should take less than 15 minutes.
Return to Tricks 'n' Tips

Who is online

Users browsing this forum: No registered users and 1 guest