How to get phone number of SMS recipient in Android
Asked Answered
C

1

6

I have seen many questions asking how to get the SMS sender's phone number, but not the recipient's phone number. I have used the tool on this site to generate a PDU and can see the recipient's phone number in it:

Useful PDU details and PDU translation tool

However, I don't see anywhere in the SmsMessage class provided by Android where I can get the recipient's phone number. The reason I want to do this is that I have a Dual SIM phone, but don't see anywhere in Android where I can determine what SIM port is being used for the incoming SMS. At the very least, I want to look at each SMS message and determine what phone number they were sent to.

This question seems very similar to mine but with no answers:

How to get SMS recipient's phone number in Android

My question is different because I have detailed a link to a site about PDUs, which may be useful for extracting the phone number form the raw PDU bytes that the SmsMessage class provides.

Any ideas?

Casket answered 13/5, 2013 at 19:12 Comment(4)
I'm also very interested in this, for the same reason, but no one seems to have answered any of the four or five questions on this on SO. However, if the information is in the PDU, the Android API offers the possibility of getting the raw PDU of a message (see here). Could we use this to get the PDU, manually decode it, and find the recipient number? – Peppard
But one problem - I cannot see any recipient number when I decode a PDU in that site... – Peppard
Answer here worked for me on Samsung a10s: #35969266 – Pascale
Did you find a solution? I am also interested in the same stuff πŸ™‚ – Epidemiology
B
2

It depends from which point you watch SMS message. SMS PDU lies on top of MAP protocol.

When you send SMS message, phone puts recipient number in TP-Destination within a PDU, when you receive SMS message, there is no recipient number anywhere. The reason for this is how SMS works. When someone sends you SMS, GSM network on his side request SRIsm message for you, that means his HLR will try to find you either in his home network, or through your home HLR. The response from HLR is IMSI number (your SIMcard) and VLR/MSC number, to where sender network must send SMS. In second packet, which is actually SMS message (Forward-MT), therefore is only your IMSI number. Since you have dual SIM, you can try to find based on this number, to which SIM card is SMS destined. Note that IMSI number is not part of the PDU but rather lower MAP protocol.

Beene answered 1/11, 2016 at 11:2 Comment(0)

© 2022 - 2024 β€” McMap. All rights reserved.