Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Link to an android application from SMS/mail

I would like to know if we can have a link in a SMS that would be handle by my application. For example a link which would look like myapp://blabla. And by clicking on it myapp would be open with the link as an argument.

This question also refers to email, either from a file with a special extension or a link like in the SMS.

Thanks a lot for your help.


Edit 31/01

Actually, I did what Greg suggested it but it doesn't work. Such a link (myapp://blabla) is not clickable in a SMS/email...When I replace myapp with http as a scheme, it works (Android asks me wether it should open the link with myapp or the browser). But myapp://blabla isn't clickable with myapp as a scheme. Here is my code:

   <application android:icon="@drawable/icon" android:label="@string/app_name"
android:debuggable="true">
<activity android:name=".myapp"
          android:label="@string/app_name"
          android:theme="@android:style/Theme.NoTitleBar"
          android:launchMode="singleTask"
          android:screenOrientation="portrait">
    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.BROWSABLE" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="myapp" android:host="blabla" />
        </intent-filter>
    </activity>

    <activity android:name=".SecondActivity"></activity>
    <activity android:name=".SettingsActivity"></activity>
</application>
like image 618
Vincent Avatar asked Nov 05 '22 04:11

Vincent


1 Answers

Yep you can with an intent filter.

Basically in your android Manifest, choose an activity that you want to be the one that handles the given url.

<activity android:name=".myactivies.MyActivity">
<intent-filter>
<action android:name="android.intent.action.VIEW"/>
<category android:name="android.intent.category.DEFAULT"/>
<data android:scheme="myapp" android:host="blabla" />
</intent-filter>
</activity>

Then inside your activity you can get the url by calling getData() on the intent.

like image 94
Greg Giacovelli Avatar answered Nov 09 '22 12:11

Greg Giacovelli