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?

有帮助吗?

解决方案

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top