In lieu of corona not having a scanner option…i am using the corona native.showWebPopup() to display a webpage that requires a barcode scanner to scan a barcode and return the result back to the page.
my issue here is that the webpage has a button that calls the http://zxing.appspot.com/scan?ret=http://website.com/page.html%3Fq%3D{CODE}
when using the phone’s browser… if the zxing barcode app is installed …the Zxing barcode app intercepts and processes this request.
my issue here is when using the native.showWebPopup() within corona the zxing barcode scanner app never sees the call & i have no clue how to setup my corona code for INTENTS to allow the barcode app to intercept/process scan requests like the regular browser would and return to native.showWebPopup() when done
All I’m trying to do here is run the website in a native.showWebPopup() so the user never leaves my app…but evokes the scanner app and returns back to native.showWebPopup() like a typical browser does.
First of all am I using the right one native.showWebPopup INSTEAD of native.newWebView() and then how do i accomplish what I’m trying to do here
any and all hep will be appreciated. I’m a newbie to corona so please go easy on me. thanks [import]uid: 136978 topic_id: 33928 reply_id: 333928[/import]
Unfortunately, you are not able to set up and launch Intents in Corona. Android Intents can get complicated enough that they really need to be implemented in Java.
I can only think of 2 options for you:
- Check if the barcode app has a URL scheme intent filter so that you can launch it via our [lua]system.openURL()[/lua] function.
- Use Corona Enterprise and code the intent yourself in Java.
[import]uid: 32256 topic_id: 33928 reply_id: 134990[/import]
Hi Joshua… Thanks once again for the help…
I tried everything & The only way I can get it to somewhat work is with the system.openURL() function.
that switches from my app and launches the phone browser…which is okay but I’d like to hide the browser bar portion so the http:/link info is hidden & not seen??
also is there anyway to switch from the browser screen to my app screen after a 30sec delay??
As usual …any help/tips will be greatly appreciated…I’m new… but learning fast… [import]uid: 136978 topic_id: 33928 reply_id: 135140[/import]
I also just noticed something interesting…possibly good
…if I hit my back button on the phone it steps back to the scanner app
…if i hit it again… it takes me back to my app screen…
is there anyway to automate/simulate the back button “press” after a time delay of say 15 secs within my lua code??
[import]uid: 136978 topic_id: 33928 reply_id: 135156[/import]
You don’t have control over the external Browser app. Also, your app will be suspended when in the Browser app, so your code won’t be running at that time. Can you access this site via the WebPopup or WebView within Corona? If so, then you’ll have control over it. [import]uid: 32256 topic_id: 33928 reply_id: 135190[/import]
Unfortunately, you are not able to set up and launch Intents in Corona. Android Intents can get complicated enough that they really need to be implemented in Java.
I can only think of 2 options for you:
- Check if the barcode app has a URL scheme intent filter so that you can launch it via our [lua]system.openURL()[/lua] function.
- Use Corona Enterprise and code the intent yourself in Java.
[import]uid: 32256 topic_id: 33928 reply_id: 134990[/import]
I can ACCESS the webpage/application via either Webpopup() or webview() or system.openURL() functions with differing levels of success
In system.openURL() function everything works like it should but I have no control in hiding the Url bar
My problem is I need to scan a barcode and then pass the result over to my website to do some server side “stuff” with it. I also need to have all the server side “stuff” hidden hence my desire to hide the URL bar.
In either webview or webpopup the scanner app never gets the INTENT to initiate the scan and send the result back… it just stays in the webpage
IDEALLY I would like to setup intents using the startActivityForResult() & onActivityResult() functions returning the barcode data in the url-encoded {CODE} %7BCODE%7D
This is what i have thus far… it initiates the scanner app grabs the barcode and freezes.
GET_BCODE = 1
startActivityForResult(ZXING, GET_BCODE)
ZXING = system.openURL( “http://zxing.appspot.com/scan?ret={CODE}” )
onActivityResult(requestCode, resultCode, data)
if (requestCode == GET_BCODE) then
native.showAlert( “step 1 ok”, event.errorMessage, { “OK” } )
end
if (resultCode == RESULT_OK) then
native.showAlert( “Result OK”, event.errorMessage, { “OK” } )
CODE = data
else
CODE = nil
end
native.showAlert( “made it this far”, event.errorMessage, { “OK” } )
native.showWebPopup(x, y, 320, 480, “http://zxing.appspot.com/scan?ret=http%3A%2F%2Fwhatsappn.com%2FXXXX%2FXXXX.html%3Fq%3D{CODE}”, options )
[import]uid: 136978 topic_id: 33928 reply_id: 135369[/import]
Hi Joshua… Thanks once again for the help…
I tried everything & The only way I can get it to somewhat work is with the system.openURL() function.
that switches from my app and launches the phone browser…which is okay but I’d like to hide the browser bar portion so the http:/link info is hidden & not seen??
also is there anyway to switch from the browser screen to my app screen after a 30sec delay??
As usual …any help/tips will be greatly appreciated…I’m new… but learning fast… [import]uid: 136978 topic_id: 33928 reply_id: 135140[/import]
I also just noticed something interesting…possibly good
…if I hit my back button on the phone it steps back to the scanner app
…if i hit it again… it takes me back to my app screen…
is there anyway to automate/simulate the back button “press” after a time delay of say 15 secs within my lua code??
[import]uid: 136978 topic_id: 33928 reply_id: 135156[/import]
You don’t have control over the external Browser app. Also, your app will be suspended when in the Browser app, so your code won’t be running at that time. Can you access this site via the WebPopup or WebView within Corona? If so, then you’ll have control over it. [import]uid: 32256 topic_id: 33928 reply_id: 135190[/import]
Unfortunately, we don’t have a good solution to do this. Not even Corona Enterprise provides easy access to onActivityResult() yet… at least not without deriving from our CoronaActivity class, which is a bit of work, but do-able. I’m afraid I can’t think of any other solution at the moment. [import]uid: 32256 topic_id: 33928 reply_id: 135500[/import]
I can ACCESS the webpage/application via either Webpopup() or webview() or system.openURL() functions with differing levels of success
In system.openURL() function everything works like it should but I have no control in hiding the Url bar
My problem is I need to scan a barcode and then pass the result over to my website to do some server side “stuff” with it. I also need to have all the server side “stuff” hidden hence my desire to hide the URL bar.
In either webview or webpopup the scanner app never gets the INTENT to initiate the scan and send the result back… it just stays in the webpage
IDEALLY I would like to setup intents using the startActivityForResult() & onActivityResult() functions returning the barcode data in the url-encoded {CODE} %7BCODE%7D
This is what i have thus far… it initiates the scanner app grabs the barcode and freezes.
GET_BCODE = 1
startActivityForResult(ZXING, GET_BCODE)
ZXING = system.openURL( “http://zxing.appspot.com/scan?ret={CODE}” )
onActivityResult(requestCode, resultCode, data)
if (requestCode == GET_BCODE) then
native.showAlert( “step 1 ok”, event.errorMessage, { “OK” } )
end
if (resultCode == RESULT_OK) then
native.showAlert( “Result OK”, event.errorMessage, { “OK” } )
CODE = data
else
CODE = nil
end
native.showAlert( “made it this far”, event.errorMessage, { “OK” } )
native.showWebPopup(x, y, 320, 480, “http://zxing.appspot.com/scan?ret=http%3A%2F%2Fwhatsappn.com%2FXXXX%2FXXXX.html%3Fq%3D{CODE}”, options )
[import]uid: 136978 topic_id: 33928 reply_id: 135369[/import]
Unfortunately, we don’t have a good solution to do this. Not even Corona Enterprise provides easy access to onActivityResult() yet… at least not without deriving from our CoronaActivity class, which is a bit of work, but do-able. I’m afraid I can’t think of any other solution at the moment. [import]uid: 32256 topic_id: 33928 reply_id: 135500[/import]
We want to override onActivityResult method for some reason.
We’re using Corona Enterprise Version 1076. But Corona does not allow
us to override this method. For overriding this method, we’re extending CoronaActivity.
When we run app on device, we get Lua Runtime Error.
Can anyone please provide the solution?
Thanks
Joshua,
Here is your statement:
" Not even Corona Enterprise provides easy access to onActivityResult() yet… at least not without deriving from our CoronaActivity class, which is a bit of work, but do-able."
Can you clarify if its doable from corona side or is it doable from developer side in enterprise?
The only way you can access the onActivityResult() method is via Corona Enterprise and deriving from our CoronaActivity class. It’s certainly doable since I know some Corona Enterprise developers have done this, but we don’t officially support this and your on your own in figuring that out… which isn’t that difficult, but you’ll have to make sure to not conflict with Corona’s result codes, ensuring that you call the super class’ method for the one you are overriding (if necessary), and update the AndroidManifest.xml to launch your derived activity class. And even then, there will be some Corona features that you can’t use such as Google push notifications, because if we detect that the Corona activity is not running, then we launch the “CoronaActivity” class explicitly via an Android intent.
We want to override onActivityResult method for some reason.
We’re using Corona Enterprise Version 1076. But Corona does not allow
us to override this method. For overriding this method, we’re extending CoronaActivity.
When we run app on device, we get Lua Runtime Error.
Can anyone please provide the solution?
Thanks
Joshua,
Here is your statement:
" Not even Corona Enterprise provides easy access to onActivityResult() yet… at least not without deriving from our CoronaActivity class, which is a bit of work, but do-able."
Can you clarify if its doable from corona side or is it doable from developer side in enterprise?
The only way you can access the onActivityResult() method is via Corona Enterprise and deriving from our CoronaActivity class. It’s certainly doable since I know some Corona Enterprise developers have done this, but we don’t officially support this and your on your own in figuring that out… which isn’t that difficult, but you’ll have to make sure to not conflict with Corona’s result codes, ensuring that you call the super class’ method for the one you are overriding (if necessary), and update the AndroidManifest.xml to launch your derived activity class. And even then, there will be some Corona features that you can’t use such as Google push notifications, because if we detect that the Corona activity is not running, then we launch the “CoronaActivity” class explicitly via an Android intent.