开发者

Launch Android app from within SMS/MMS message?

Is it possible to to launch 开发者_StackOverflowan application using a URL launched from within the Android messaging app (SMS or MMS)?


The previous answer was not correct.

You can add an intent filter for an activity that will "register" your app to handle hyperlinks within the SMS body.

For instance, if you add the following intent to your application.xml:

<intent-filter>
  <action android:name="android.intent.action.VIEW"></action>
  <category android:name="android.intent.category.DEFAULT"></category>
  <category android:name="android.intent.category.BROWSABLE"></category>
  <data 
    android:scheme="http" 
    android:host="test.com" 
    android:pathPrefix="/myapp">
  </data>
</intent-filter>

And you send an SMS message with the following in the body:

http://test.com/myapp/somedata

Your application will launch and the activity will be able to access the URL as part of the intent data.


In addition answer given by @Adam,

There is multiple intent filter possible in case of android app, We have to use two. One for the app launcher and one for the launching app using the URL in sms

<activity android:name="com.SomeActivity" adroid:theme="@style/MyTheme"
android:label="@string/app_name"> 
    <!-- For app launcher -->
    <intent-filter>
       <action android:name="android.intent.action.MAIN" />
       <category android:name="android.intent.category.LAUNCHER" />
       <category android:name="com.YorAppPackage" />
    </intent-filter>
    <!-- To open app using link -->
    <intent-filter>
        <action android:name="android.intent.action.VIEW"></action>
        <category android:name="android.intent.category.DEFAULT"></category>
        <category android:name="android.intent.category.BROWSABLE"></category>
        <data android:scheme="http"
              android:host="yourdomain.com"
              android:pathPrefix="/someurlparam">
        </data>
    </intent-filter>
</activity>

Now add a URL in your sms something like

http://yourdomain.com/someurlparam

This should launch the app on url click and will add a app icon in android as well.


No, the only URL recognized are:

  • Web URLs.
  • Email addresses.
  • Phone numbers.
  • Map addresses.

From TextView's android:autoLink XML attribute.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜