tags:

views:

369

answers:

3

recieve text sms to specific port.. I have been looking for an answer to this question but but to no avail. This question has been popped 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 Reciever 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 recieve the SMS on the specified port. Once i remove the following line its works fine

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

could you suggest me what am i missing??

A: 

Hi, have you managed to find a solution to this?

jonney
A: 

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>
3dmg
A: 

If it doesn't work for you, why not receive the SMS and then sending it programmatically to the port instead of letting Android handle it?

http://developer.android.com/reference/java/net/Socket.html

Sotapanna