Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

launch application from browser url scheme

Thanks to many good posts, I have bee trying to launch my Android app from a browser link using the following code. Please help me adjust the manifest and href to call my application -

Manifest

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  package="com.afs"
  android:versionCode="1"
  android:versionName="1.1">
  <supports-screens
  android:largeScreens="true"
    android:normalScreens="true"
    android:smallScreens="false"
    android:resizeable="true"
    android:anyDensity="true"/>
<uses-permission android:name="android.permission.INTERNET"></uses-permission>
<uses-permission android:name="android.permission.CALL_PHONE"></uses-permission>
<uses-permission android:name="android.permission.SEND_SMS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_SETTINGS"></uses-permission>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"></uses-permission>
<uses-permission android:name="android.permission.MODIFY_PHONE_STATE"></uses-permission>
<uses-permission android:name="android.permission.READ_PHONE_STATE"></uses-permission>
<uses-sdk android:minSdkVersion="9"></uses-sdk>
<application android:label="@string/app_name" android:icon="@drawable/afs"        android:debuggable="true">
      <activity android:name=".afs"
              android:label="@string/app_name"
              android:configChanges="keyboardHidden|orientation"
        android:screenOrientation="portrait">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
         <intent-filter>
             <data android:scheme="afs.com.afs"/>
             <data android:name="android.intent.action.VIEW" />
             <category android:name="android.intent.category.DEFAULT" />
             <category android:name="android.intent.category.BROWSABLE" />
         </intent-filter>    
    </activity>
</application>

HTML code

<a href="afs.com.afs:75235">Launch Application</a>
like image 618
user1751607 Avatar asked Nov 30 '12 11:11

user1751607


1 Answers

Attributes from documentation scheme://host:port/path or pathPrefix or pathPattern.

You need to change define proprely scheme and host definition. If you don't specify scheme then all URI attributes will be ignored, and won't be applied.

You could use http URI scheme.

    <data android:scheme="http" android:host="afs.com.afs"/>

and in HTML

<a href="http://afs.com.afs:75235">Launch Application</a>

Or define own URL scheme.

    <data android:scheme="myapp" android:host="afs.com.afs"/>

and in HTML

<a href="myapp://afs.com.afs:75235">Launch Application</a>

PS.

Change this

    <data android:name="android.intent.action.VIEW" />

to

    <action android:name="android.intent.action.VIEW" />
like image 66
Przemysław Piechota. kibao Avatar answered Oct 04 '22 18:10

Przemysław Piechota. kibao