31

I know that for opening android application from a link inside a web page we have to write the following in the AndroidManifest.xml:

        <intent-filter>
            <action android:name="android.intent.action.VIEW"/>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="my_scheme" android:host="my_host" />
        </intent-filter>

The problem is that I wrote it in the following way:

        <intent-filter>
            <action android:name="my_action"/>
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="my_scheme" android:host="my_host" />
        </intent-filter>

I didn't add android.intent.action.VIEW and instead I added my own action that i made. I can't change it because the version is already released.

The question is,

if there's a way to make the application run from JavaScript or simple html page, maybe by defining the specific action in the page?

Thanks,

Paz.


SOLVED:

Thanks to David I found a solution:

<a href="intent://my_host#Intent;scheme=my_scheme;action=my_action;end">Link to my stuff</a> 
Asad Ali Choudhry
  • 4,985
  • 4
  • 31
  • 36
Paz
  • 365
  • 2
  • 4
  • 8

4 Answers4

35

Try this:

Make your links look like this:

<a href="intent:#Intent;action=my_action;end">Link to my stuff</a>

Also have a look at Launch custom android application from android browser

Community
  • 1
  • 1
David Wasser
  • 93,459
  • 16
  • 209
  • 274
  • Thanks David, what do you mean by intent:#Intent? shouldn't it be my_scheme://my_host or should i write it as it is (intent:#Intent)? – Paz Aug 02 '12 at 21:21
  • I've not tried this myself, but it looks like you can launch an Intent from a web browser by using this link format. I don't think your `myscheme://my_host` URL will work in this case because the browser will just create an Intent with `action=android.intent.action.VIEW` and this won't match your Intent filter. You'll need to play with it some. Let me know if you figure it out. – David Wasser Aug 03 '12 at 07:44
  • 1
    Hi David, since i'm using host and scheme, this is the full solution: Link to my stuff thanks for your help. – Paz Aug 05 '12 at 08:30
  • Hey, if I want to open a web site in google chrome for android how it would be? What should I put in intent? and in my action? – Matheus Oliveira Nov 18 '16 at 15:13
  • @MatheusOliveira please open a new question. Asking your question in a comment on this answer isn't the way to get an answer. If you ask a new question you are more likely to get some attention. – David Wasser Nov 18 '16 at 16:12
  • My two cents ....If the link goes inside an HTML email does not work because Gmail remove this kind of hiperlinks. – danipenaperez May 31 '17 at 13:57
  • i want sent parameters like username and password in intent how to sent can anyone help? – Pradeep Bishnoi Apr 16 '18 at 09:20
  • @PradeepBishnoi Please open a new question. Asking a question in a comment like this isn't going to get you the help you need. Good luck! – David Wasser Apr 16 '18 at 09:23
  • Docs for `intent:` syntax can be found here: https://developer.chrome.com/multidevice/android/intents – David Sep 16 '19 at 12:44
6

AndroidMainfest declare:

<activity android:name="...">
<intent-filter>    
   <action android:name="android.intent.action.VIEW" />
   <category android:name="android.intent.category.DEFAULT" />    
   <category android:name="android.intent.category.BROWSABLE" />
   <data
     android:host="hostName"
     android:path="path"
     android:scheme="schemeName" />
   </intent-filter>
</activity>

you can let to invoke

<a href = "schemeName://hostName/path">

or add param similar url in brower

<a href = "schemeName://hostName/path?id=1&name=mark">
林平君
  • 111
  • 1
  • 2
1

One way as 林平君 saied,and another way by invoking js method ,code as follow:

function openAActivity(){
     window.location = "schemeName://hostName/path"

}

this method will send an Android intent to start specified activity.

aolphn
  • 2,950
  • 2
  • 21
  • 30
-5

1st way:

<html><head></head><body>
<iframe src="YourApp://profile/blabla" width="1px" height="1px" scrolling="no" frameborder="0"></iframe>
<script>
setTimeout(function() {
window.location = "http://YourSite.com/profile/blabla"; }, 4000
                );
</script>
</body>
</html>

OR
2nd way: https://stackoverflow.com/a/24023048/2165415

Community
  • 1
  • 1
T.Todua
  • 53,146
  • 19
  • 236
  • 237