Question

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?

Was it helpful?

Solution

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).

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top