0

I am adding App Links to an Android app. It is working well, but I am now considering failure cases.

If I can't retrieve the information I need from the URI, then I want to send the URL back to be opened by a web browser. If I attempt to start an activity with the bad URL it just ends up coming back to my app again.

Is there a way to send the URL back to be opened by another app?

zorro2b
  • 2,227
  • 4
  • 28
  • 45

1 Answers1

0

One way to do this is outside the Android system.

Have your website check if it has the required params and then construct the scheme.

For example, if you have a website say https://example.com, you can check for params in the url, parse it and then only send the url with valid params rest can be handle by your website using a javascript like the one below

 var userAgent = navigator.userAgent || navigator.vendor || window.opera;
 var paramA = getURLParameter('paramA'),
    paramB = getURLParameter('paramB'),
    paramC = getURLParameter('paramC');
 if( userAgent.match( /Android/i ) ) {
    setTimeout(function () { window.location = 'https://play.google.com/store/apps/details?id=com.myapp.myapp'; }, 5000);
    if(paramA) {
        window.location = 'example://param/' + paramA;
    } else if(paramB) {
        window.location = 'example://param/' + paramB;
    } else if(paramC) {
        window.location = 'example://param/' + paramC;
    }
    setWindowLocation();
}

This will also help the case of redirecting user to the mobile/full site when your app is not installed.

SanthoshN
  • 619
  • 3
  • 15