1

First of all, I'm very new to Android, I need you to be very specific and clear when you're explaining something - to the question:

I have a JSP page, which is displayable in my phone. What I want to accomplish is to open an app - in the phone, from my JSP page.

My JSP page looks like this so far:

<td> <button type="button" class="btn btn-xs btn-primary openAppButton">Open App</button></td>

I have no JavaScript/jQuery yet because I don't know how to do this.

My Android App is just a recently created "Hello World" by the name "MainActivity".

Does anyone have any idea of how to do this? Is this possible using jQuery/Ajax?

Any help is greatly appreciated!

Dr Cox
  • 149
  • 6
  • 35
  • Possible duplicate of [android custom url scheme..?](http://stackoverflow.com/questions/4023273/android-custom-url-scheme) – Adam Azad Jan 22 '16 at 09:47
  • @AdamAzad I want to open an app as an "onclick" from a jsp-page, if that's called "android url scheme" or not, I do not know. – Dr Cox Jan 22 '16 at 09:48
  • yea the link to open the app would look something like this ( Take a QR code ) -- https://developer.chrome.com/multidevice/android/intents – Tasos Jan 22 '16 at 09:55
  • @Tasos Interesting, do you know where I can find this url for my own app? – Dr Cox Jan 22 '16 at 10:00
  • in your manifest or at the top of your main activity you see the package name or at the app structure in the right window in AS just above main activity file -- and replace this (com.google.zxing.client.android‌​) in the link – Tasos Jan 22 '16 at 10:02
  • @Tasos Do I add "scheme" and "intent" aswell? or just the package? I'm sorry i'm so confused – Dr Cox Jan 22 '16 at 10:06
  • not sure exactly, you probably need to add that extra info as shown in the 1st comment link in your manifest file – Tasos Jan 22 '16 at 10:11

1 Answers1

1

I added this to the Androidmanifest.xml:

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

It now looks like this:

<manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.mattte"
      android:versionCode="1"
      android:versionName="1.0">
<application android:label="@string/app_name" android:icon="@drawable/ic_launcher">
    <activity android:name="MainActivity"
              android:label="@string/app_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
        <intent-filter>
            <data android:scheme="matte"/>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" /> 
        </intent-filter>
    </activity>
</application>

And finally, I could open the app using this link:

<td> <button type="button" class="btn btn-xs btn-primary" onClick="location.href='matte://com.mattte.MainActivity'">Open App</button></td>

Now it works perfectly fine.

Dr Cox
  • 149
  • 6
  • 35