Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why android deep linking makes my link on Whatsapp opened inside Whatsapp's App?

I am following this tutorial step by step for making deep linking on Android. Part of the code is as follows, basically it will open the url in my App's webview.

Intent intent = getIntent();
String action = intent.getAction();
Uri data = intent.getData();
if (data != null) {
    String path = data.getPath();
    String query = data.getEncodedQuery();
    String hash = data.getEncodedFragment();

    String fullPath = path;
    if(query !=  null){
        fullPath = path + "?" + query;
        if(hash != null){
            fullPath = path + "#" + hash;
        }
    }

    String openUrl = "https://" + Config.domain + fullPath;

    ....
    // and open in webview

}

It almost works perfectly. Links on the Chrome browser can be opened in my app. However, when clicking on links on messaging app such as Whatsapp, the link is opened on Whatsapp itself, by replacing the original content on Whatsapp! And I cannot return to the normal messaging screen of Whatsapp unless I quit the app and open it again!

Why is it behaving like that and what do I have to do to fix it? Thanks!

like image 602
user2335065 Avatar asked Oct 20 '25 14:10

user2335065


1 Answers

I had the exact same problem and it was because I had the "launchMode" setted to singleTop. I changed it to singleTask and it worked perfectly.

like image 168
Carlos Avatar answered Oct 22 '25 05:10

Carlos