0

When users enter my mobile website, I want to detect that a user installed my specific app or not, then If it installed, I want to redirect my user to my native app.

I tried below

HTML

<a class="intent" href="http://mymobilewebsite"  data-scheme="myApp://"></a> 

Javascript

(function () {

            goToUri($("a.intent").data('scheme'), $("a.intent").attr('href'));
            event.preventDefault();

            function goToUri(uri, href) {
                var start, end, elapsed;

                start = new Date().getTime();
                document.location = uri;

                end = new Date().getTime();

                elapsed = (end - start);

                if (elapsed < 1) {
                    document.location = href;
                }
            }               
        })();

this does not work at all.

I searched how youtube does that because I know when I type youtube ton google and click youtube's mobile website link, android asking me to perform to complete that action on youtube app.

Here Screen Shot from my mobile

How youtube achieve that perform, could not find out ?

Edit : My Question pointed as duplicated, in my question, I am asking that I want to solve this problem only in mobile website

Mehmet Eren Yener
  • 2,006
  • 1
  • 23
  • 37
  • 1
    You can find the answer to your question [here](http://stackoverflow.com/questions/2958701/launch-custom-android-application-from-android-browser). – Cristian Neagu Jun 30 '15 at 14:39

1 Answers1

-1

Use this in ur class

private class MyWebViewClient extends WebViewClient {
    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        if (url.equals("YOURLINK")) {
            Intent intent = new Intent(getContext(), YourActivity.class);
            startActivity(intent);
            return false;
        }else{
            view.loadURL(url);
            return true;
        }
    }
}

You can start any kind of files i.e audio, video or image anything.

Mathivanan
  • 371
  • 2
  • 16