github coronalabs/corona 3651
Solar2D 2021.3651

latest releases: 3706, 3705, 3704...
3 years ago

Changes since previous build:

  • Android: fixing licensing check (b0a1e61)

Android API level 30

Android introduced breaking change in Android 11 (api 30) which we are now targeting). Major change affecting system.canOpenURL() call. It now requires to list all schemes you'll use in the build.setting (AndroidManifest.xml).
Hovewer, due to quicks with Android implementation, even listing scheme sometimes gives the wrong result (for example, if user chose to always use the App to open https://twitter.com links, the query for this URL would return false if no special <query> element is added. Confusing, indeed.
Current recommendation is use openURL instead o canOpenURL. It will always return reliable result, if URL was handled.
For example, consider following code:

	local mapURL = "https://maps.google.com/maps?q=Hello,+Solar2D!@" .. currentLatitude .. "," .. currentLongitude
	if system.canOpenURL( mapURL ) then
		-- Show location on map
		system.openURL( mapURL )
	else
		native.showAlert( "Alert", "No browser found to show location on map!", { "OK" } )
	end

Is better written as

	local mapURL = "https://maps.google.com/maps?q=Hello,+Solar2D!@" .. currentLatitude .. "," .. currentLongitude
	if not system.openURL( mapURL ) then
		native.showAlert( "Alert", "No browser found to show location on map!", { "OK" } )
	end

Latter code would work realiably without need to add any manifest entries via build.settings.

Example entries

If you do want to query if some app can handle URL, here are some code examples for your build.settings:

settings =
{
    android =
    {
        manifestChildElements = 
        {
            [[
            <queries>
                <package android:name="com.facebook.katana" />
                <package android:name="com.instagram.android" />
                <intent>
                    <action android:name="android.intent.action.VIEW" />
                    <data android:scheme="http" />
                </intent>
            </queries>
            ]],
        },
    },
}

Read more about following change at the android developers blog.

Discuss on Forums: https://forums.solar2d.com/t/android-api-level-30-is-here-in-3650/353821

Don't miss a new corona release

NewReleases is sending notifications on new releases.