11 Replies Latest reply on Jul 3, 2012 10:35 AM by Darryn Campbell

    Simple scanning on a Moto device

    DANIEL PARK

      Team,

      Do we still need to add the barcode-moto extension to the build.yml in order to get the scanner going on a Motorola device?

       

       

      I am having trouble getting the scanner activated on a Moto device with a simple Rhomobile program

       

      I have the barcode extension in the Build.yml as per below:

       

      extensions

      - barcode-moto

       

       

      The code I am using in the controller.rb to invoke the scanner is as follows:

       

      def take

            scanners = Barcode.enumerate()

            scanner = scanners[0]['name']

            puts "take - using scanner: #{scanner}"

            Barcode.enable(url_for(:action => :take_callback), {:name=>scanners[0]['name']})

            redirect :action => :wait

          end

         

        def take_callback

            status = @params['status']

            barcode = @params['barcode']

       

            puts 'take_callback'

            puts 'status = '+status.to_s unless status == nil

            puts 'barcode = '+barcode.to_s unless barcode == nil

       

            WebView.navigate(url_for(:action => :index))

       

            if status == 'ok'

                Alert.show_popup(

                    :message => "Barcode["+barcode.to_s+"]",

                    :title => "Take barcode",

                    :buttons => ["Ok"]

                )

            elsif status == 'cancel'

                Alert.show_popup(

                    :message => "Barcode taking was canceled !",

                    :title => "Take barcode",

                    :buttons => ["Ok"]

                )

            end

       

      And in the wait.erb I have:

       

      <div data-role="page" data-add-back-btn="false">

       

         <div data-role="content">

          <div> waiting for barcode... </div>

        </div>

      </div>

       

      Any assistance would be appreciated.

      regards,

      Daniel