Android: register application to Send/Compose sms

2019-08-21 09:34发布

问题:

How can I register my application so that when I press compose sms button or even send sms my app appears in dialog Complete action using ? I have put that code to Manifest file (note NewMessageActivity sends sms) but it's not working.

    <activity
        android:name=".NewMessageActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />

            <category android:name="android.intent.category.DEFAULT" />

            <action android:name="android.intent.action.SENDTO" />

            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />

            <data android:mimeType="text/plain" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
        </intent-filter>
    </activity>

Any help ? Any suggestions ? Thanks !

回答1:

Try adding this permission:

<uses-permission android:name="android.permission.SEND_SMS"/>


回答2:

So I finally found the right answer in the following link android: register application to receive sms

<activity
        android:name="az.elman.grouptextfree.NewMessageActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <category android:name="android.intent.category.DEFAULT" />                
            <data android:mimeType="vnd.android-dir/mms-sms" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.SENDTO" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="sms" />
            <data android:scheme="smsto" />
        </intent-filter>
        <intent-filter>
            <action android:name="android.intent.action.SEND" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:mimeType="text/plain" />
        </intent-filter>
    </activity>

Also do not forget to add this permission <uses-permission android:name="android.permission.SEND_SMS"/> to your Manifest file as Jbad26 wrote.



回答3:

Android has brought-in the concept of 'Default SMS app' on KitKat. That is, the user can set an app, which is going to handle the sending / receiving of SMS, through Settings. So, if you want your app to be listed under default SMS apps category, your app needs to handle sending / receiving of SMS, MMS etc.. Please refer the link below for more information

http://android-developers.blogspot.com/2013/10/getting-your-sms-apps-ready-for-kitkat.html



标签: android sms