Created
October 15, 2012 12:50
-
-
Save spritle/3892292 to your computer and use it in GitHub Desktop.
Scanner Code
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#application.rb | |
# Avoid, the scanner gets auto started when device starts up. | |
# Avoid, the scanner gets auto started when application start. | |
def on_activate_app | |
begin | |
Scanner.stop | |
rescue | |
end | |
end | |
#app/layout.erb | |
<meta http-equiv="PowerOn" content="PowerOnEvent:url('/app/TransferDetail/stop_scanner')"> | |
# In controller's we use | |
def activate_scanner | |
Scanner.enabled = "SCN2" | |
# Only a sample code, the actual callback event method is controller and context specific. | |
Scanner.decodeEvent = "/app/TransferDetail/take_barcode_callback?hardware_scan=false" | |
end | |
# This will be called after we call activate_scanner method | |
# The method set_scanner_status will toggle "start" and "stop". This is used by "soft button". | |
def set_scanner_status | |
if Rho::RhoConfig.SCANNER_STATUS == "0" || Rho::RhoConfig.SCANNER_STATUS == "" | |
Scanner.start | |
WebView.execute_js("toggleScannerUI(1)") | |
Rho::RhoConfig.SCANNER_STATUS = "1" | |
else | |
Scanner.stop | |
WebView.execute_js("toggleScannerUI(0)") | |
Rho::RhoConfig.SCANNER_STATUS = "0" | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment