Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to receive text sms to specific port..

Tags:

android

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 clear answer. My code is as follows:

--MANIFEST FILE--

<receiver android:name=".SMSRecieve" android:enabled="true"> 
<intent-filter> 
<action android:name="android.intent.action.DATA_SMS_RECEIVED"/> 
<data android:scheme="sms" /> 
<data android:host="localhost" /> 
<data android:port="15005" /> 
</intent-filter> 
</receiver>

--SMS sending method--

String messageText = msgTxt.getText().toString(); 
short SMS_PORT = 15005; 
SmsManager smsManager = SmsManager.getDefault(); 
smsManager.sendDataMessage("5556", null, SMS_PORT, messageText.getBytes(), null, null); 

--Broadcast Receiver code--

static final String ACTION = "android.intent.action.DATA_SMS_RECEIVED"; 
//static final String ACTION = "android.provider.Telephony.SMS_RECEIVED";(tried this too, but failed) 

if (intent.getAction().equals(SMSNotifyExample.ACTION)) { 
...do some work.. 
}

I also tried to replace android:name to android.provider.Telephony.SMS_RECEIVED but the result is the same.

My application does not receive the SMS on the specified port. Once I remove the following line it works fine:

<data android:scheme="sms" /> 
<data android:host="localhost" /> 
<data android:port="15005" /> 

Could you suggest what am I missing?

like image 533
Umesh Avatar asked Apr 28 '10 05:04

Umesh


People also ask

What port is SMS on?

For the Web2SMS interface, the SMS will be sent using the HTTP(S) API. Port 80 and / or 443 must be open for this purpose. For the Email2SMS, the SMS will be sent using the SMTP API.

Can I receive SMS messages on my PC?

Any SMS messages received will be forwarded to your computer / PC using a protocol / interface supported by the SMSC or SMS gateway. Get access to the SMS gateway of an SMS service provider. Any SMS messages received will be forwarded to your computer / PC using a protocol / interface supported by the SMS gateway.


2 Answers

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>
like image 160
3dmg Avatar answered Sep 29 '22 22:09

3dmg


[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.

like image 30
Siddhant Avatar answered Sep 29 '22 22:09

Siddhant