Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] Android ACTION_VIEW intent is not opening urls in non-browser apps like twitter and instagram

Posted on November 11, 2022 By

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.

READ  [FIXED] android - Is there any way I can uninstall an app from my device using Flutter?
Powered by Inline Related Posts

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?

READ  [FIXED] java - Get EditText input values and display some calculation result in an TextView
Powered by Inline Related Posts

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

Android Tags:android, android-intent, unreal-engine4

Post navigation

Previous Post: [FIXED] android developer api – there is a ‘Late Initialization Error’ during flutter development
Next Post: [FIXED] android – How to set SSL pinning using retrofit for Firebase Realtime Database Url?

Related Posts

[FIXED] java – My google places SDK doesn’t seem to work after trying multiple options. What could the issue be? Android
[FIXED] android – How can I turn on flashlight in old devices Android
[FIXED] java – READ_SETTINGS permission needed to launch gmaps with intent on WEAR OS Android
[FIXED] Code to launch an app from a given list in Android Android
[FIXED] Xamarin.forms – Trouble behaviour between ListView & keyboard Android
[FIXED] android – How to animate (slide in from bottom) visibility change of view on fragment which is bottom alignment? Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What color are dead flea eggs?
  • What is Indiana vine?
  • What’s the downside of a Chromebook?
  • Is phosphide the same as phosphorus?
  • Why do you need an S bend?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme