Reputation: 13511
I'm building an app that needs to report some information about outgoing SMS messages. As I understand that a single Android device can house a different SIM card at any point in time, is there a way to look at the mobile number of the SIM card that sent a particular SMS message?
My current approach to looking at the sent SMSes is via a ContentObserver
to content://sms
, and while I can retrieve info such as the sending date, the target number, and the message body, I can't find a column from the Cursor
that contains the device's mobile number when that message was sent. I also don't mind taking a different approach.
Upvotes: 1
Views: 1477
Reputation: 21637
There is no guaranteed solution to this problem because the phone number is not physically stored on all SIM-cards, or broadcasted from the network to the phone. This is especially true in some countries which requires physical address verification, with number assignment only happening afterwards. Phone number assignment happens on the network - and can be changed without changing the SIM card or device (e.g. this is how porting is supported). I know it is pain, but most likely the best solution is just to ask the user to enter his/her phone number once and store it.
Upvotes: 1