2

I'm using SMSLib to read messages from a specified gateway, the piece of code used for reading the messages is :

List<InboundMessage> msgList = new ArrayList<InboundMessage>();

        Service.getInstance().readMessages(msgList, MessageClasses.ALL);
        for (InboundMessage msg : msgList)
            System.out.println(msg);    

The point here that i want to get the phone number that send this message to the gateway, is that possible? and it yes, how?

Muhammed Refaat
  • 8,914
  • 14
  • 83
  • 118

1 Answers1

4

Use msg.getOriginator();

Note that the SMS protocol does not require the phone number of the sender to be present,(and it might even be text, and not a phone number).

nos
  • 223,662
  • 58
  • 417
  • 506