Handling URL scheme on Android?

Thanks for sharing!

Out of interest, what issues were you having with a “singleTask” activity?

The only odd quirk that I’m aware of is if you display an activity from a singleTask activity, home out, and then go back to your app… then Android automatically destroys all of the activities displayed by that task and goes back to the singleTask activity.

I did a test application based on an example above from Joshua and a sample for Pic2Shop integration. I’m using Android right now.

I’m calling QR scanner pic2shop and specify a callback. What happens is that the application is called after scanning image but no data is passed. I also did a test with my own application to start this code and found that it only works if application is cold started, not on resume.

I had to add a native.requestExit(); to get it to work but I dont want to close the application and I had other side effetcs like returning to pic2shop scanner.

-- Example showing how to integrate Pic2Shop Barcode Scanning into a Corona APP -- Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license -- Copyright (C) 2013 Minion Multimedia. All Rights Reserved. local scanButton local information scanButton = display.newRect( 10, 50, 100, 50 ) scanButton:setFillColor ( 244 ) information = display.newText( "Press Above to Scan", 10, 120, 200, 0, native.systemFont, 20 ) local function buttonTouch ( event ) if event.phase == "ended" then system.openURL( "pic2shop://scan?callback=yourapp%3A") end end scanButton:addEventListener ( "touch", buttonTouch ) -- Prints all contents of a Lua table to the log. local function printTable(table, stringPrefix) if not stringPrefix then stringPrefix = "### " end if type(table) == "table" then for key, value in pairs(table) do if type(value) == "table" then print(stringPrefix .. tostring(key)) print(stringPrefix .. "{") printTable(value, stringPrefix .. " ") print(stringPrefix .. "}") else print(stringPrefix .. tostring(key) .. ": " .. tostring(value)) end end end end local launchArguments = ... if launchArguments then print("yourapp: ### --- Launch Arguments ---") printTable(launchArguments) end local launchURL local function onSystemEvent( event ) print( "yourapp: onSystemEvent [" .. tostring(event.type) .. "] URL: " .. tostring(event.url) ) if event.type == "applicationSuspend" then --native.requestExit(); elseif event.type == "applicationOpen" and event.url then -- Prints all launch arguments printTable(event) launchURL = event.url information.text = "Raw: " .. event.url print( launchURL ) -- output: coronasdkapp://mycustomstring local testA = string.find ( launchURL, "=" ) if tostring(testA) ~= "nil" then barCodeFinal = string.sub ( launchURL, testA + 1 ) information.text = information.text .. "\n" .. "Afterwards: " .. barCodeFinal information.x = 10 end end end Runtime:addEventListener( "system", onSystemEvent )

build.settings look like this for the URL scheme parts.

android = { intentFilters = { { label = "Optional Title Goes Here", actions = { "android.intent.action.VIEW" }, categories = { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme = "yourapp" }, }, -- You can add more intent filters here. }, },

Am I missing something?

The data would be passed to your app via an Android intent.  Corona provides *all* of this intent information via launch arguments on startup or the “applicationOpen” event upon resume.  The print functions in your code should print all of the information in the Android intent that launched your app to the Android log, which you can view via the Android SDK’s “adb logcat”.  If the QR scanner is providing a file, then odds are it is passing it as a file path or URL via this Android intent.  Unfortunately, there is no standard, so you’ll have to view this information via the log to see how it is delivered.  If it’s not a file path and it is a URL delivered via an Android ContentProvider (with a URL scheme of “content://”), then you can only access that file via native code.

When doing cold start of application logcat gives me this

03-19 22:33:51.005: I/Corona(19993): yourapp: ### — Launch Arguments —
03-19 22:33:51.005: I/Corona(19993): ### androidIntent
03-19 22:33:51.005: I/Corona(19993): ### {
03-19 22:33:51.005: I/Corona(19993): ###    categories
03-19 22:33:51.005: I/Corona(19993): ###    {
03-19 22:33:51.005: I/Corona(19993): ###       1: android.intent.category.LAUNCHER
03-19 22:33:51.005: I/Corona(19993): ###    }
03-19 22:33:51.005: I/Corona(19993): ###    url:
03-19 22:33:51.005: I/Corona(19993): ###    action: android.intent.action.MAIN
03-19 22:33:51.005: I/Corona(19993): ###    extras
03-19 22:33:51.005: I/Corona(19993): ###    {
03-19 22:33:51.005: I/Corona(19993): ###    }
03-19 22:33:51.005: I/Corona(19993): ### }
03-19 22:33:51.005: I/Corona(19993): ### url:
03-19 22:33:51.005: I/Corona(19993): yourapp: onSystemEvent [applicationStart] URL: nil
03-19 22:33:52.910: I/Corona(19993): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:33:53.025: I/Corona(19993): yourapp: onSystemEvent [applicationResume] URL: nil

After pic2shop scanner

03-19 22:36:02.395: I/Corona(19993): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:36:05.440: I/Corona(19993): yourapp: onSystemEvent [applicationResume] URL: nil
03-19 22:36:05.440: I/Corona(19993): yourapp: onSystemEvent [applicationOpen] URL: nil
03-19 22:36:05.440: I/Corona(19993): nil

when I add native.requestExit() when app is suspended I get this from pic2shop

03-19 22:39:11.285: I/Corona(23208): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:39:12.355: I/Corona(23208): yourapp: onSystemEvent [applicationExit] URL: nil
03-19 22:39:16.830: V/Corona(23695): > Class.forName: network.LuaLoader
03-19 22:39:16.830: V/Corona(23695): < Class.forName: network.LuaLoader
03-19 22:39:16.830: V/Corona(23695): Loading via reflection: network.LuaLoader
03-19 22:39:16.835: I/Corona(23695): Platform: GT-I9300 / ARM Neon / 4.3 / Mali-400 MP / OpenGL ES 2.0
03-19 22:39:16.870: V/Corona(23695): > Class.forName: CoronaProvider.licensing.google.LuaLoader
03-19 22:39:16.875: V/Corona(23695): < Class.forName: CoronaProvider.licensing.google.LuaLoader
03-19 22:39:16.880: V/Corona(23695): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
03-19 22:39:16.905: I/Corona(23695): yourapp: ### — Launch Arguments —
03-19 22:39:16.905: I/Corona(23695): ### androidIntent
03-19 22:39:16.905: I/Corona(23695): ### {
03-19 22:39:16.905: I/Corona(23695): ###    categories
03-19 22:39:16.905: I/Corona(23695): ###    {
03-19 22:39:16.905: I/Corona(23695): ###    }
03-19 22:39:16.905: I/Corona(23695): ###    url: yourapp:?ean=8806085215733
03-19 22:39:16.905: I/Corona(23695): ###    action: android.intent.action.VIEW
03-19 22:39:16.905: I/Corona(23695): ###    extras
03-19 22:39:16.905: I/Corona(23695): ###    {
03-19 22:39:16.905: I/Corona(23695): ###       com.android.browser.application_id: com.visionsmarts.pic2shop
03-19 22:39:16.905: I/Corona(23695): ###    }
03-19 22:39:16.905: I/Corona(23695): ### }
03-19 22:39:16.905: I/Corona(23695): ### url: yourapp:?ean=8806085215733
03-19 22:39:16.905: I/Corona(23695): yourapp: onSystemEvent [applicationStart] URL: nil
03-19 22:39:25.780: I/Corona(23695): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:39:26.595: I/Corona(23695): yourapp: onSystemEvent [applicationExit] URL: nil

as you can see only launch args contains information about intent. Never in the event applicationOpen.

The “applicationOpen” event will only provide pic2shop’s intent information if it is “resuming” your app.  That is, it must have been previously suspended such as via the Home button.  If you “back” out of your app, then that exits and the intent information will be provided via the launch arguments again.

So, do this.  Launch your app, then suspend it via the Home button, go to the pic2shop app, and then in then trigger your app’s intent-filter to resume it.  You’ll see the pic2shop intent information in your “applicationOpen” event.  If you’re seeing launch arguments instead, then that means that the operating system killed your app after you suspended it (or you unknowingly killed it in your suspend code).

I’m experiencing the exact same thing.   If I kill the app by hand first, I get the proper data from the launchArguments, but if I then go back to the gallery (via Home), the applicationOpen event is triggered without it showing any intent data.     So the second time I’m not seeing the launch arguments nor the data on the applicationOpen event.

I can confirm what Claes has mentioned: the launchArguments url is always empty except when we explicitly do native.requestExit() on suspend. 

Setup:

Test App calls “pic2shop://scan?callback=test://ag123/EAN”. 

Test app is suspended. 

pic2shop gets triggered (opens), the barcode is scanned. The barcode decoded value should ideally be passed in the EAN section. 

Test app resumes, but no url value. 

During normal operations (without explicit exit):

V/Corona ( 303): \> Class.forName: network.LuaLoader V/Corona ( 303): \< Class.forName: network.LuaLoader V/Corona ( 303): Loading via reflection: network.LuaLoader I/Corona ( 303): Platform: Nexus 4 / ARM Neon / 4.4.2 / Adreno (TM) 320 / OpenGL ES 3.0 V@53.0 AU@ (CL@) V/Corona ( 303): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 303): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 303): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationStart I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationSuspend I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationResume I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationOpen I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: 

(no URL passed in above case)

But when using explicit exit on suspend, we do get the URL:

V/Corona (29644): \> Class.forName: network.LuaLoader V/Corona (29644): \< Class.forName: network.LuaLoader V/Corona (29644): Loading via reflection: network.LuaLoader I/Corona (29644): Platform: Nexus 4 / ARM Neon / 4.4.2 / Adreno (TM) 320 / OpenGL ES 3.0 V@53.0 AU@ (CL@) V/Corona (29644): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### 1: android.intent.category.LAUNCHER I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): ### action: android.intent.action.MAIN I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationStart I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### 1: android.intent.category.LAUNCHER I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): ### action: android.intent.action.MAIN I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationSuspend I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### 1: android.intent.category.LAUNCHER I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): ### action: android.intent.action.MAIN I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationExit ------- this is the explicit exit V/Corona (29644): \> Class.forName: network.LuaLoader V/Corona (29644): \< Class.forName: network.LuaLoader V/Corona (29644): Loading via reflection: network.LuaLoader I/Corona (29644): Platform: Nexus 4 / ARM Neon / 4.4.2 / Adreno (TM) 320 / OpenGL ES 3.0 V@53.0 AU@ (CL@) V/Corona (29644): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): ### action: android.intent.action.VIEW I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### com.android.browser.application\_id: com.visionsmarts.pic2shop I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationStart I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): ### action: android.intent.action.VIEW I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### com.android.browser.application\_id: com.visionsmarts.pic2shop I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationSuspend I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): ### action: android.intent.action.VIEW I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### com.android.browser.application\_id: com.visionsmarts.pic2shop I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationExit

As can be seen,  url: test://ag123/8809376760059  has been populated this time. 

But this is not a very practical (or recommended?) approach to kill off the app everytime we suspend it? 

Please advise. 

Cheers,

Anshuman

Anshuman,

I tested this today and confirmed that the “applicationOpen” event is *not* providing the “androidIntent” information.  This is indeed a bug in the newest release, because this feature used to work.  I’ve written up a bug report for this issue and added it to our queue.  No ETA at the moment.

Hi Joshua, Thanks for the investigation update. 

It would be good to have it sorted in the near future to avoid exiting apps instead of suspending them as a workaround. 

Many thanks for filing the bug.

Cheers,

Anshuman

This has been fixed in build 2224.

Great news! :slight_smile:

I have tested the latest version and verified that it is working as it should. Thanks!

-Claes

I did a test application based on an example above from Joshua and a sample for Pic2Shop integration. I’m using Android right now.

I’m calling QR scanner pic2shop and specify a callback. What happens is that the application is called after scanning image but no data is passed. I also did a test with my own application to start this code and found that it only works if application is cold started, not on resume.

I had to add a native.requestExit(); to get it to work but I dont want to close the application and I had other side effetcs like returning to pic2shop scanner.

-- Example showing how to integrate Pic2Shop Barcode Scanning into a Corona APP -- Sample code is MIT licensed, see http://www.coronalabs.com/links/code/license -- Copyright (C) 2013 Minion Multimedia. All Rights Reserved. local scanButton local information scanButton = display.newRect( 10, 50, 100, 50 ) scanButton:setFillColor ( 244 ) information = display.newText( "Press Above to Scan", 10, 120, 200, 0, native.systemFont, 20 ) local function buttonTouch ( event ) if event.phase == "ended" then system.openURL( "pic2shop://scan?callback=yourapp%3A") end end scanButton:addEventListener ( "touch", buttonTouch ) -- Prints all contents of a Lua table to the log. local function printTable(table, stringPrefix) if not stringPrefix then stringPrefix = "### " end if type(table) == "table" then for key, value in pairs(table) do if type(value) == "table" then print(stringPrefix .. tostring(key)) print(stringPrefix .. "{") printTable(value, stringPrefix .. " ") print(stringPrefix .. "}") else print(stringPrefix .. tostring(key) .. ": " .. tostring(value)) end end end end local launchArguments = ... if launchArguments then print("yourapp: ### --- Launch Arguments ---") printTable(launchArguments) end local launchURL local function onSystemEvent( event ) print( "yourapp: onSystemEvent [" .. tostring(event.type) .. "] URL: " .. tostring(event.url) ) if event.type == "applicationSuspend" then --native.requestExit(); elseif event.type == "applicationOpen" and event.url then -- Prints all launch arguments printTable(event) launchURL = event.url information.text = "Raw: " .. event.url print( launchURL ) -- output: coronasdkapp://mycustomstring local testA = string.find ( launchURL, "=" ) if tostring(testA) ~= "nil" then barCodeFinal = string.sub ( launchURL, testA + 1 ) information.text = information.text .. "\n" .. "Afterwards: " .. barCodeFinal information.x = 10 end end end Runtime:addEventListener( "system", onSystemEvent )

build.settings look like this for the URL scheme parts.

android = { intentFilters = { { label = "Optional Title Goes Here", actions = { "android.intent.action.VIEW" }, categories = { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme = "yourapp" }, }, -- You can add more intent filters here. }, },

Am I missing something?

The data would be passed to your app via an Android intent.  Corona provides *all* of this intent information via launch arguments on startup or the “applicationOpen” event upon resume.  The print functions in your code should print all of the information in the Android intent that launched your app to the Android log, which you can view via the Android SDK’s “adb logcat”.  If the QR scanner is providing a file, then odds are it is passing it as a file path or URL via this Android intent.  Unfortunately, there is no standard, so you’ll have to view this information via the log to see how it is delivered.  If it’s not a file path and it is a URL delivered via an Android ContentProvider (with a URL scheme of “content://”), then you can only access that file via native code.

When doing cold start of application logcat gives me this

03-19 22:33:51.005: I/Corona(19993): yourapp: ### — Launch Arguments —
03-19 22:33:51.005: I/Corona(19993): ### androidIntent
03-19 22:33:51.005: I/Corona(19993): ### {
03-19 22:33:51.005: I/Corona(19993): ###    categories
03-19 22:33:51.005: I/Corona(19993): ###    {
03-19 22:33:51.005: I/Corona(19993): ###       1: android.intent.category.LAUNCHER
03-19 22:33:51.005: I/Corona(19993): ###    }
03-19 22:33:51.005: I/Corona(19993): ###    url:
03-19 22:33:51.005: I/Corona(19993): ###    action: android.intent.action.MAIN
03-19 22:33:51.005: I/Corona(19993): ###    extras
03-19 22:33:51.005: I/Corona(19993): ###    {
03-19 22:33:51.005: I/Corona(19993): ###    }
03-19 22:33:51.005: I/Corona(19993): ### }
03-19 22:33:51.005: I/Corona(19993): ### url:
03-19 22:33:51.005: I/Corona(19993): yourapp: onSystemEvent [applicationStart] URL: nil
03-19 22:33:52.910: I/Corona(19993): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:33:53.025: I/Corona(19993): yourapp: onSystemEvent [applicationResume] URL: nil

After pic2shop scanner

03-19 22:36:02.395: I/Corona(19993): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:36:05.440: I/Corona(19993): yourapp: onSystemEvent [applicationResume] URL: nil
03-19 22:36:05.440: I/Corona(19993): yourapp: onSystemEvent [applicationOpen] URL: nil
03-19 22:36:05.440: I/Corona(19993): nil

when I add native.requestExit() when app is suspended I get this from pic2shop

03-19 22:39:11.285: I/Corona(23208): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:39:12.355: I/Corona(23208): yourapp: onSystemEvent [applicationExit] URL: nil
03-19 22:39:16.830: V/Corona(23695): > Class.forName: network.LuaLoader
03-19 22:39:16.830: V/Corona(23695): < Class.forName: network.LuaLoader
03-19 22:39:16.830: V/Corona(23695): Loading via reflection: network.LuaLoader
03-19 22:39:16.835: I/Corona(23695): Platform: GT-I9300 / ARM Neon / 4.3 / Mali-400 MP / OpenGL ES 2.0
03-19 22:39:16.870: V/Corona(23695): > Class.forName: CoronaProvider.licensing.google.LuaLoader
03-19 22:39:16.875: V/Corona(23695): < Class.forName: CoronaProvider.licensing.google.LuaLoader
03-19 22:39:16.880: V/Corona(23695): Loading via reflection: CoronaProvider.licensing.google.LuaLoader
03-19 22:39:16.905: I/Corona(23695): yourapp: ### — Launch Arguments —
03-19 22:39:16.905: I/Corona(23695): ### androidIntent
03-19 22:39:16.905: I/Corona(23695): ### {
03-19 22:39:16.905: I/Corona(23695): ###    categories
03-19 22:39:16.905: I/Corona(23695): ###    {
03-19 22:39:16.905: I/Corona(23695): ###    }
03-19 22:39:16.905: I/Corona(23695): ###    url: yourapp:?ean=8806085215733
03-19 22:39:16.905: I/Corona(23695): ###    action: android.intent.action.VIEW
03-19 22:39:16.905: I/Corona(23695): ###    extras
03-19 22:39:16.905: I/Corona(23695): ###    {
03-19 22:39:16.905: I/Corona(23695): ###       com.android.browser.application_id: com.visionsmarts.pic2shop
03-19 22:39:16.905: I/Corona(23695): ###    }
03-19 22:39:16.905: I/Corona(23695): ### }
03-19 22:39:16.905: I/Corona(23695): ### url: yourapp:?ean=8806085215733
03-19 22:39:16.905: I/Corona(23695): yourapp: onSystemEvent [applicationStart] URL: nil
03-19 22:39:25.780: I/Corona(23695): yourapp: onSystemEvent [applicationSuspend] URL: nil
03-19 22:39:26.595: I/Corona(23695): yourapp: onSystemEvent [applicationExit] URL: nil

as you can see only launch args contains information about intent. Never in the event applicationOpen.

The “applicationOpen” event will only provide pic2shop’s intent information if it is “resuming” your app.  That is, it must have been previously suspended such as via the Home button.  If you “back” out of your app, then that exits and the intent information will be provided via the launch arguments again.

So, do this.  Launch your app, then suspend it via the Home button, go to the pic2shop app, and then in then trigger your app’s intent-filter to resume it.  You’ll see the pic2shop intent information in your “applicationOpen” event.  If you’re seeing launch arguments instead, then that means that the operating system killed your app after you suspended it (or you unknowingly killed it in your suspend code).

I’m experiencing the exact same thing.   If I kill the app by hand first, I get the proper data from the launchArguments, but if I then go back to the gallery (via Home), the applicationOpen event is triggered without it showing any intent data.     So the second time I’m not seeing the launch arguments nor the data on the applicationOpen event.

I can confirm what Claes has mentioned: the launchArguments url is always empty except when we explicitly do native.requestExit() on suspend. 

Setup:

Test App calls “pic2shop://scan?callback=test://ag123/EAN”. 

Test app is suspended. 

pic2shop gets triggered (opens), the barcode is scanned. The barcode decoded value should ideally be passed in the EAN section. 

Test app resumes, but no url value. 

During normal operations (without explicit exit):

V/Corona ( 303): \> Class.forName: network.LuaLoader V/Corona ( 303): \< Class.forName: network.LuaLoader V/Corona ( 303): Loading via reflection: network.LuaLoader I/Corona ( 303): Platform: Nexus 4 / ARM Neon / 4.4.2 / Adreno (TM) 320 / OpenGL ES 3.0 V@53.0 AU@ (CL@) V/Corona ( 303): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 303): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona ( 303): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationStart I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationSuspend I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationResume I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): App State: I/Corona ( 303): ### name: system I/Corona ( 303): ### type: applicationOpen I/Corona ( 303): yourapp: ### --- Launch Arguments --- I/Corona ( 303): ### androidIntent I/Corona ( 303): ### { I/Corona ( 303): ### categories I/Corona ( 303): ### { I/Corona ( 303): ### 1: android.intent.category.LAUNCHER I/Corona ( 303): ### } I/Corona ( 303): ### url: I/Corona ( 303): ### action: android.intent.action.MAIN I/Corona ( 303): ### extras I/Corona ( 303): ### { I/Corona ( 303): ### } I/Corona ( 303): ### } I/Corona ( 303): ### url: 

(no URL passed in above case)

But when using explicit exit on suspend, we do get the URL:

V/Corona (29644): \> Class.forName: network.LuaLoader V/Corona (29644): \< Class.forName: network.LuaLoader V/Corona (29644): Loading via reflection: network.LuaLoader I/Corona (29644): Platform: Nexus 4 / ARM Neon / 4.4.2 / Adreno (TM) 320 / OpenGL ES 3.0 V@53.0 AU@ (CL@) V/Corona (29644): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### 1: android.intent.category.LAUNCHER I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): ### action: android.intent.action.MAIN I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationStart I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### 1: android.intent.category.LAUNCHER I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): ### action: android.intent.action.MAIN I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationSuspend I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### 1: android.intent.category.LAUNCHER I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): ### action: android.intent.action.MAIN I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationExit ------- this is the explicit exit V/Corona (29644): \> Class.forName: network.LuaLoader V/Corona (29644): \< Class.forName: network.LuaLoader V/Corona (29644): Loading via reflection: network.LuaLoader I/Corona (29644): Platform: Nexus 4 / ARM Neon / 4.4.2 / Adreno (TM) 320 / OpenGL ES 3.0 V@53.0 AU@ (CL@) V/Corona (29644): \> Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): \< Class.forName: CoronaProvider.licensing.google.LuaLoader V/Corona (29644): Loading via reflection: CoronaProvider.licensing.google.LuaLoader I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): ### action: android.intent.action.VIEW I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### com.android.browser.application\_id: com.visionsmarts.pic2shop I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationStart I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): ### action: android.intent.action.VIEW I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### com.android.browser.application\_id: com.visionsmarts.pic2shop I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationSuspend I/Corona (29644): yourapp: ### --- Launch Arguments --- I/Corona (29644): ### androidIntent I/Corona (29644): ### { I/Corona (29644): ### categories I/Corona (29644): ### { I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): ### action: android.intent.action.VIEW I/Corona (29644): ### extras I/Corona (29644): ### { I/Corona (29644): ### com.android.browser.application\_id: com.visionsmarts.pic2shop I/Corona (29644): ### } I/Corona (29644): ### } I/Corona (29644): ### url: test://ag123/8809376760059 I/Corona (29644): App State: I/Corona (29644): ### name: system I/Corona (29644): ### type: applicationExit

As can be seen,  url: test://ag123/8809376760059  has been populated this time. 

But this is not a very practical (or recommended?) approach to kill off the app everytime we suspend it? 

Please advise. 

Cheers,

Anshuman

Anshuman,

I tested this today and confirmed that the “applicationOpen” event is *not* providing the “androidIntent” information.  This is indeed a bug in the newest release, because this feature used to work.  I’ve written up a bug report for this issue and added it to our queue.  No ETA at the moment.

Hi Joshua, Thanks for the investigation update. 

It would be good to have it sorted in the near future to avoid exiting apps instead of suspending them as a workaround. 

Many thanks for filing the bug.

Cheers,

Anshuman

This has been fixed in build 2224.