10 Replies Latest reply on Mar 22, 2013 9:34 AM by Luca Priano

    RHOElements Runtime: scanner javascript api seems not firing events

    Luca Priano

      Hi guys,

       

      I'm trying to use RHOElements Runtime (not licensed) to access with JavaScript API to the device scanner. I'm using Samsung Galaxy S3 (Android)

       

      I'm trying to use the sample (http://docs.rhomobile.com/rhoelements/scanner) which should display the available scanners on screen, but the enumScannerEvent semms not firing !!! Anyway the scanner object isn't undefined. I've also tried to use meta tag but with the same result.

       

      Here is the sample code:

       

      <HTML>

            <HEAD> 

                     <meta http-equiv="quitbutton" content="visibility:visible;" />

       

                      <SCRIPT LANGUAGE="JavaScript">

       

                                                        function EnumScanners(jsonObject)

                                                        {

                                                                       alert("EnumScanners");   // I DON'T SEE THIS !!!!! 

                                                        }

       

                                                        //  Wait for the DOM to fully load before we enumerate the scanners

                                                          function setEnumScannerTimer()

                                                           {

                                                                       setTimeout("onScannerEnable()", 3000);

                                                        }

       

                                                        function onScannerEnable()

                                                        {

                                                                       scanner.enumScannerEvent="EnumScanners(%json);";

                                                                       scanner.enumerate();

       

                                                                       alert("scanner " + scanner);

                                                      }

       

                               </SCRIPT>

       

                </HEAD>

       

                <BODY onLoad="setEnumScannerTimer();">

                               <DIV ID="message"></DIV>

                 </BODY>

      </HTML>

       

      Can somebody give me a hint?

      Is it possible try scanner javascript API with a not licensed  RHOElements Runtime?

       

      Thanks a lot in advance!

      Luca

        • Re: RHOElements Runtime: scanner javascript api seems not firing events
          Peter Arcuri

          Yes, all APIs work without a RhoElements license. However, the Scanner API works only for MSI devices along with its scan engine hardware. Non-MSI devices can use the barcode api which would leverage the camera hardware.

           

          See API matrix (all devices) under Mobile API compatibility for details.

           

          http://docs.rhomobile.com/rhoelements/apicompatibility

          .

          1 of 1 people found this helpful
            • Re: RHOElements Runtime: scanner javascript api seems not firing events
              Luca Priano

              Thanks Peter. I've read on barcode api page description that "You must have a RhoElements license to use the JavaScript API", so without license can I only use Ruby to try barcode API?

                • Re: RHOElements Runtime: scanner javascript api seems not firing events
                  Peter Arcuri

                  All APIs are functional even without a license key. The term 'requires a RhoElements license" identifies which APIs are licensable. Apps are fully functionable without a license so to faciliate the developmet, testing and debugging, though with the nag screen. One can purchase the physical license key once ready for production deployment..

                   

                  Hope this helps.

                  1 of 1 people found this helpful
                    • Re: RHOElements Runtime: scanner javascript api seems not firing events
                      Luca Priano

                      Thanks a lot Peter, I ask you a last clue yet.

                       

                      If I've understood I can read a barcode with my galaxy S3, using RhoElements Runtime (not licensed) and Barcode API.

                       

                      • I've read it's necessary this include public/js/rho_javascript_api.js ...but there isn't any link to download it. Is it already included in the RhoElements Runtime? ...I've supposed it is.
                      • I've made this attempt, but without success (Rho.barcode is undefined...) ...could you please give me a clue where I'm wrong?

                       

                       

                      <HTML>

                                <HEAD>

                                     <meta http-equiv="quitbutton" content="visibility:visible;" />

                       

                                     <SCRIPT LANGUAGE="JavaScript" SRC="public/js/rho_javascript_api.js"></SCRIPT>

                                     <SCRIPT LANGUAGE="JavaScript">

                       

                                           function init() {  


                                                 try{

                                                      Rho.Barcode.take_barcode(myCallback);

                                                  }

                                                  catch(e){

                                                       alert(e.description);   //  UNDEFINED !!!!  

                                                  }

                                        }

                       

                                       function myCallback(barCode){

                       

                                             alert(barCode);

                                        }

                       

                                  </SCRIPT>

                             </HEAD>

                       

                             BODY onLoad="init();"></BODY>

                      </HTML>

                       

                       

                      Thanks a lot in advance,

                      Luca

                        • Re: RHOElements Runtime: scanner javascript api seems not firing events

                          rho_javascript_api.js resides in the rhoelement runtime application, so doing

                              <SCRIPT LANGUAGE="JavaScript" SRC="public/js/rho_javascript_api.js"></SCRIPT>

                          would do nothing, cause you wont be able to fetch this from your webserver, unless you really have a copy of this javascript file in your web server directory.

                          You can get the file though from your rhostudio installation directory,

                              C:\MotorolaRhoMobileSuite2.2.1.13\ruby\lib\ruby\gems\1.9.1\gems\rhoelements-2.2.1.13\libs\rho-javascript\public\js

                          and paste it into your web application directory.

                          • Re: RHOElements Runtime: scanner javascript api seems not firing events
                            Peter Arcuri

                            Luca, i've done some digging on the barcode api and found that the javascript support is specifically for a RhoElements native app (Rhodes-based). You can view this as embedded javascript support the Rhodes framework, hence creating native apps.

                            I believe you want to create a html/javascript web-app served by a web-server. Since the "barcode" api doesn't support meta tags for HTML I suspect your desired app architecture may be challenging, at least until RhoMoSuite v4 is released in late April timeframe.

                             

                            In the meantime, you could develop a native app and create a .apk package through the Rhodes framework and target consumer-based Android devices. As stated in Docs.Rhomobile.com there is a sample app for using the barcode api in the RhoStudio install files. For example:

                             

                            D:\MotorolaRhoMobileSuite2.2.1.12\samples\rhodes-system-api-samples\app\BarcodeRecognizer

                             

                            I suggest checking out Rob Galvin's way to minimizing code on the client by allowing your javascript (including barcode api) to run off the webserver and call it via Webview.navigate call. This still requires a native app though.

                            https://developer.motorolasolutions.com/message/8182#8182

                             

                            If you're wondering how your desired architecture is acheivable with a Motorola Android devices (ET1 & MC40), it's through the scanner api which would check for a scan engine to decode barcodes and if that fails it will default to the camera. While we strive to supporting devices capabilities of non-MSI devices, today the scanner api supports only Motorola Solutions Inc equipment.

                             

                            Hope this helps.