how to receive text sms to specific port..

后端 未结 2 1494
暖寄归人
暖寄归人 2020-12-05 03:48

How to receive text sms to a specific port? I have been looking for an answer to this question but to no avail. This has been asked a few times but nobody seems to have a cl

相关标签:
2条回答
  • 2020-12-05 04:12

    [NOTE: The code that i have mentioned below is not working on the emulator but successfully on my LG P350 having Android V2.3]

    I have used the demo code given on mobiForge but have changed the sendTextMessage() to sendDataMessage() with PORT_NO as 8901 (also converted text data to byte[] data). My receiver is:

    <receiver android:name=".SMSReceiver"> 
            <intent-filter>
            <action android:name="android.intent.action.DATA_SMS_RECEIVED" /> 
                <data android:scheme="sms" /> 
                <data android:port="8901" /> 
            </intent-filter> 
    </receiver> 
    

    A working example is KRVarma's SMSDemo which is also functional.

    0 讨论(0)
  • 2020-12-05 04:20

    Thanks for the hint!

    I use this and it works:

            <receiver android:name=".SMSReceiver">
            <intent-filter android:priority="10">
            <action android:name="android.intent.action.DATA_SMS_RECEIVED" />
                <data android:scheme="sms" />
                <data android:port="50009" />
            </intent-filter>
        </receiver>
    
    0 讨论(0)
提交回复
热议问题