Solution 1 :
Your understanding is right until Google released App Links Verification.
It means the domain owner(in your example Twitter, Netflix, etc.) have added Digital Asset Links JSON that are associated with the website and verify the app’s URL intents. Hence they have proved that they are the only app that can handle https://twitter.com. Here you can see this JSON https://www.twitter.com/.well-known/assetlinks.json
Solution 2 :
The best solution seems to upgrade the Unreal Engine Project to 4.27 which includes the following commit:
https://github.com/EpicGames/UnrealEngine/commit/e49afc395b171e1d0c39e2d79b16ca2be8ea982c
This adds BrowserIntent.addCategory(Intent.CATEGORY_BROWSABLE); to the function that is responsible for starting the intent and thereby makes it work for devices with target SDK 30.
Problem :
I’m struggling with making social-buttons work within an android app on android 12. The buttons are intended to simply open a URL (e.g. https://twitter.com/netflix). By my understanding the view intent should be automatically handed over to the proper app, which is able to handle it. So in case of a twitter url, with the twitter app installed, it should open the twitter app. In case no specific app is installed, it should open the URL using the default browser.
What I experience is that URLs like https://google.com are properly opened in the browser. But when trying to open https://twitter.com/netflix, there is just nothing happening. The URL is not opening in the browser, nor in the twitter app. But when uninstalling twitter, the URL opens in the browser as expected.
So I guess I’m missing something to make non-browser apps handle the URL as expected.
Strange thing: when opening https://twitter.com, the twitter app opens instead of the browser.
This is what I have in the queries element of my manifest file:
<queries>
<intent>
<action android_name="android.intent.action.VIEW" />
<category android_name="android.intent.category.DEFAULT" />
<category android_name="android.intent.category.BROWSABLE" />
</intent>
</queries>
Also: This is an unreal engine based project, so the code used for opening/launching the URL using an ACTION_VIEW intent is part of the engine source code. Ideally I want to find a solution to make this work without having to modify this engine code. Here the code snipped that is responsible for opening the URL:
public void AndroidThunkJava_LaunchURL(String URL)
{
Log.debug("[JAVA} AndroidThunkJava_LaunchURL: URL = " + URL);
if (!URL.contains("://"))
{
// add http:// if there isn't a scheme before a colon
if (URL.indexOf(":") < 1)
{
URL = "http://" + URL;
Log.debug("[JAVA} AndroidThunkJava_LaunchURL: corrected URL = " + URL);
}
}
try
{
Intent BrowserIntent = new Intent(Intent.ACTION_VIEW, android.net.Uri.parse(URL));
// open browser on its own task
BrowserIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY | Intent.FLAG_ACTIVITY_CLEAR_WHEN_TASK_RESET);
BrowserIntent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
// make sure there is a web browser to handle the URL before trying to start activity (or may crash!)
if (BrowserIntent.resolveActivity(getPackageManager()) != null)
{
Log.debug("[JAVA} AndroidThunkJava_LaunchURL: Starting activity");
startActivity(BrowserIntent);
}
else
{
Log.debug("[JAVA} AndroidThunkJava_LaunchURL: Could not find an application to receive the URL intent");
}
}
catch (Exception e)
{
Log.debug("[JAVA} AndroidThunkJava_LaunchURL: Failed with exception " + e.getMessage());
}
}
Comments
Comment posted by twitter.com/netflix
Create a Web page. Put a link to
Comment posted by FBAM.Studio
Good point! I gave this a quick try (using a web page) and the link is properly opening in the twitter app. I’m pretty sure there is something missing on my end / Unreal Engine. I saw a change to the Unreal Engine code (the one I sent above) which was done to tackle this issue. It is adding BrowserIntent.addCategory(Intent.CATEGORY_BROWSABLE); before adding the flags to the intent. Is it possible that this category, missing from the intent, is responsible for what I experience?
Comment posted by CommonsWare
“Is it possible that this category, missing from the intent, is responsible for what I experience?” — that’s a good possibility. Unfortunately, Google has limited documentation on your side of the “app links” story. Mostly, it documents Twitter’s side: how to advertise and respond to them. However, generally, a Web browser is going to include