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!

7
  • Possible duplicate of android custom url scheme..? Commented Jan 22, 2016 at 9: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. Commented Jan 22, 2016 at 9:48
  • yea the link to open the app would look something like this ( <a href="intent://scan/#Intent;scheme=zxing;package=com.google.zxing.client.android;end"> Take a QR code </a>) -- developer.chrome.com/multidevice/android/intents Commented Jan 22, 2016 at 9:55
  • @Tasos Interesting, do you know where I can find this url for my own app? Commented Jan 22, 2016 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 Commented Jan 22, 2016 at 10:02

1 Answer 1

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.