Android custom URL scheme

I have:

 intentFilters = { { label = "\<my app\>", actions = { "android.intent.action.VIEW" }, categories = { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme = "zoneInit", host="com.krustypetes.davida.customurl" }, },

in my build.settings to create a custom url in an Android App.

When passing: zoneInit://?sData=[xxxxxxxxxx] in either an email or sms, neither is recognizing it as a link and therefore won’t start the app.

Question 1: how can I be sure that the URL scheme was actually created?  and

Question 2: I’ve read that it is up to the device to recognize (or not) the scheme and determine how it responds to it.  If so, is there a better, consistent way to execute the scheme and start the app?

Thanks

Ok.   I’ve used adb to verify that the url scheme was created and is properly passing the arguments on the applicationStart and applicationOpen events.

The adb command is:

adb shell am start -a android.intent.action.VIEW -d “zoneInit://data=[yXXXXXXXXXXXXXXXy]” com.krustypetes.davida.customurl

I have also edited the code above in build.settings to take a host parameter, to be more in line with what android developer docs show for the intent.

Further, I’ve seen references to “clicking the link” in both the browser and sms messages, but cant seem to get either to show (and then react to) a link.  Chrome takes me to a google search and the sms message just wont show a link.

Any suggestions?

I’ve just tested the following.  It definitely works.

-- "build.settings" settings = { android = { intentFilters = { { label = "Custom URL Scheme Test", actions = { "android.intent.action.VIEW" }, categories = { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme = "mycustomtest" }, }, }, }, }

My HTML file…

\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"\> \<html xmlns="http://www.w3.org/1999/xhtml"\> \<head\> \<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /\> \<title\>My Test\</title\> \</head\> \<body\> Tap the below link to launch the Android app via a custom URL scheme. \<br/\> \<br/\> \<a href="mycustomtest://Hello/World"\>mycustomtest://Hello/World\</a\> \</body\> \</html\>

You may want to double check your “build.settings” for typos, missing commas, etc.

Thanks, Joshua.

I appreciate the example.  I verified using adb that the custom scheme is setup and working - the problem seems to be that the SMS programs only recognize “normal” schemes such as “http://” or a phone number as linkable, and treat everything else as just text.

I went to this:

 intentFilters = { { label = "for app launcher", actions = { "android.intent.action.MAIN" }, categories = { "android.intent.category.LAUNCHER", "com.krustypetes.davida.customurl", }, }, { label = "my app", actions = { "android.intent.action.VIEW" }, categories = { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme="http", host="sdInit", pathPrefix="/data" }, }, -- You can add more intent filters here. },

which, since I used http in scheme, it is recognized in the SMS text as a link (and is clickable),  When clicked, I’m asked whether to use Chrome or my app - just once or always.  clicking my app gets the expected results.  I guess that now I’m looking to find a way to avoid the selection question.

thanks

Great! I’m glad you got it working. And setting the “host” is a good way to do it, although I think Google normally expects you to set it to a full domain such as “sdInit.com” or something like that (but you might be able to get away with it).

Regarding the 3rd party app asking which app it should launch, unfortunately, you have no control over that.  And this is not a Corona limitation either.  What’s happening is that app is using what’s called an “intent chooser”.  You can see an example of this in Google’s examples here…

   https://developer.android.com/training/sharing/send.html

This means that the 3rd party app is specifically coded to call Intent.createChooser() which will always display a choice of apps to the user.

Ok.   I’ve used adb to verify that the url scheme was created and is properly passing the arguments on the applicationStart and applicationOpen events.

The adb command is:

adb shell am start -a android.intent.action.VIEW -d “zoneInit://data=[yXXXXXXXXXXXXXXXy]” com.krustypetes.davida.customurl

I have also edited the code above in build.settings to take a host parameter, to be more in line with what android developer docs show for the intent.

Further, I’ve seen references to “clicking the link” in both the browser and sms messages, but cant seem to get either to show (and then react to) a link.  Chrome takes me to a google search and the sms message just wont show a link.

Any suggestions?

I’ve just tested the following.  It definitely works.

-- "build.settings" settings = { android = { intentFilters = { { label = "Custom URL Scheme Test", actions = { "android.intent.action.VIEW" }, categories = { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme = "mycustomtest" }, }, }, }, }

My HTML file…

\<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"\> \<html xmlns="http://www.w3.org/1999/xhtml"\> \<head\> \<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /\> \<title\>My Test\</title\> \</head\> \<body\> Tap the below link to launch the Android app via a custom URL scheme. \<br/\> \<br/\> \<a href="mycustomtest://Hello/World"\>mycustomtest://Hello/World\</a\> \</body\> \</html\>

You may want to double check your “build.settings” for typos, missing commas, etc.

Thanks, Joshua.

I appreciate the example.  I verified using adb that the custom scheme is setup and working - the problem seems to be that the SMS programs only recognize “normal” schemes such as “http://” or a phone number as linkable, and treat everything else as just text.

I went to this:

 intentFilters = { { label = "for app launcher", actions = { "android.intent.action.MAIN" }, categories = { "android.intent.category.LAUNCHER", "com.krustypetes.davida.customurl", }, }, { label = "my app", actions = { "android.intent.action.VIEW" }, categories = { "android.intent.category.DEFAULT", "android.intent.category.BROWSABLE", }, data = { scheme="http", host="sdInit", pathPrefix="/data" }, }, -- You can add more intent filters here. },

which, since I used http in scheme, it is recognized in the SMS text as a link (and is clickable),  When clicked, I’m asked whether to use Chrome or my app - just once or always.  clicking my app gets the expected results.  I guess that now I’m looking to find a way to avoid the selection question.

thanks

Great! I’m glad you got it working. And setting the “host” is a good way to do it, although I think Google normally expects you to set it to a full domain such as “sdInit.com” or something like that (but you might be able to get away with it).

Regarding the 3rd party app asking which app it should launch, unfortunately, you have no control over that.  And this is not a Corona limitation either.  What’s happening is that app is using what’s called an “intent chooser”.  You can see an example of this in Google’s examples here…

   https://developer.android.com/training/sharing/send.html

This means that the 3rd party app is specifically coded to call Intent.createChooser() which will always display a choice of apps to the user.