androiddeep-linkingandroid-deep-link

Android, the app gets stuck in an infinite loop when I try to open a link, that exist in the manifest file


I have scenerio where I deeplink url : www.business.co.uk/some_search?someparams=data

I have 2 cases, I send this link to a backend service where the params is extracted and returned to my app to perform a search based on that result.

The second scenario is when the backend fails to sanitise this link, I want to open the link in a webBrowser.

The Issue: Because I have the path in my manifest, when my backend service returns the same link. I open that link in a browser. I get into a scenario where the OS thinks my app can handle the URI and deeplinks it again, and i get stuck in an infinite loop.

I can change that path, and it looks like the manifest can only access the path and can't touch the query params,( i was hoping i could had a query params but this din't wor either).

does have a nice solution, I can prevent this infinite loop, to make it so when my app opens a browser it don't deeplink.

I tried adding a extra param to stop the deeplink, but the param can't be indentified an the manifest level, so this deeplink always happen no matter what. I can't change my path and as you can see it is small path so not much can be done.


Solution

  • Intent filter based on query param will be supported in Android 15

    Android 15 Query param intent filter

    For now you can use either a WebView or AndroidX browser library to open url you get from your server.

    AndroidX browser library using this you can directly launch a chrome tab in app.

    implementation ‘androidx.browser:browser:1.0.0’
    

    Alternatively you can open in webview as below

     webView = (WebView) findViewById(R.id.webView1);
     webView.getSettings().setJavaScriptEnabled(true);
     webView.loadUrl("http://www.google.com");