2

I have a web page that I want to detect my Android App (in background) using intent-filter of course, so my App and my page do their work separately.

My android application handles a URL like the URL below using intent-filter:

myApp://sample?param=1

So I have an <a> tag in my page which I clicked it using JavaScript (automatically):

<a href="myApp://sample?param=1" id="myAppLink"></a>

Everything works fine exept when I don't have my App installed (for example in PC or iOS).
In this situation the browser redirects to myApp://sample?param=1 (naturally).

Is there any way (in JavaScript I think) that I can detect if the app not handled my URL then I stop automatic clicking? Or other way (tricks of course) to know if the App installed then I call click event? Or some other workarounds to my problem?

Or can I call my URL (myApp://sample?param=1) using AJAX or JSONP so my App detects it?
(I've tried this with jQuery Ajax without a chance. I don't know if the intent-filter could handle Ajax requests.)

Vahid
  • 3,384
  • 2
  • 35
  • 69

2 Answers2

0

Unfortunately you cannot check from the web if any applications is installed on the device, because of privacy issues.

See similar question.

Community
  • 1
  • 1
NickF
  • 5,637
  • 12
  • 44
  • 75
  • Of course we cannot check that. But I need a tricky way with intent-filter if anyone has any idea... – Vahid Jul 01 '14 at 05:11
0

As a workaround, you can identify an intent pointing to your server link, using http:// instead of myApp:// :

<data android:host="yourhost.com" data android:path="/apath" android:scheme="http" />

for ...

<a href="http://yourhost.com/apath?param=1" id="myAppLink"></a>

If your app exists it will redirect to the app (the user will need to confirm the first time), if not, it will call the link where you host a page that will answer properly for desktop (using PHP, java, nodejs, or whatever).

atorres
  • 402
  • 4
  • 11