0

I'm using a port for sending Data message in my app.

I have a problem with sending data message (sendDataMessage in android). my code works properly with MCI sim cards, I mean when the sender and receiver have MCI sim cards.

If sender has a MCI and receiver has an Irancell sim card message delivers properly.

On the contrary, if sender has an Irancell sim and receiver has a MCI sim it is not delivered at all :( (although in this case text message send/receive works properly, data message won't work).

Moreover when sender and receiver have Irancell sims it works properly. please help me with this problem.

My manifest code:

<receiver android:name=".SmsListener">
    <intent-filter android:priority="999">
        <action android:name="android.intent.action.DATA_SMS_RECEIVED" />
        <intent-filter android:priority="999">
            <action android:name="android.provider.Telephony.SMS_RECEIVED" />
        </intent-filter>
        <data android:scheme="sms" />
        <data android:port="7442" />
    </intent-filter>
    <intent-filter android:priority="1000">
        <action android:name="android.provider.Telephony.SMS_RECEIVED" />
    </intent-filter>
</receiver>
<meta-data android:name="port" android:value="7442" />

My smsListener:

public void onReceive(Context context, Intent intent)     
    {
        Toast.makeText(context, "Yuhuuu", Toast.LENGTH_LONG).show();
        MainActivity.smsReceived(true);
        Bundle bundle = intent.getExtras();
        String recMsgString = "";
        String fromAddress = "";
        SmsMessage recMsg = null;
        byte[] data = null;
        if (bundle != null) {
            Object[] pdus = (Object[]) bundle.get("pdus");
            for (int i = 0; i < pdus.length; i++) {
                recMsg = SmsMessage.createFromPdu((byte[]) pdus[i]);

                try {
                    data = recMsg.getUserData();
                } catch (Exception e) {

                }
                if (data != null) {
                    for (int index = 0; index < data.length; ++index) {
                        recMsgString += Character.toString((char) data[index]);
                    }
                }
                fromAddress = recMsg.getOriginatingAddress();
            }
        }
        System.out.println(recMsgString + " ,this Has been Recieved from: " + fromAddress);
    }

and my DataMessage sender code:

 String messageText = "some text";
        short SMS_PORT = 7442;
        SmsManager smsManager = SmsManager.getDefault();
        String phoneNumber = "+98910*******";
        smsManager.sendDataMessage(phoneNumber, null, shortValue, messageText, null, null);

}

ai68
  • 1
  • 2
  • You might try using `"*"` for the ``'s `port`, and see if it's somehow getting delivered to the wrong one. Otherwise, I'd say it's probably a network transmission problem that you're not going to be able to do anything about yourself. – Mike M. May 24 '16 at 17:26
  • not working yet :( – ai68 May 24 '16 at 17:33

0 Answers0