0
我想學習使用SMSlib使用中興MF631 USB調制解調器發送短信。這裏是我的代碼:沒有網關定義SMSlib
Service.getInstance().startService();
SerialModemGateway gateway = new SerialModemGateway("modem.com5","COM5", 115200, "ZTE", "MF631");
gateway.setInbound(true);
gateway.setOutbound(true);
gateway.setSimPin("0000");
gateway.setSmscNumber("+9779800009000");
try {
Service.getInstance().addGateway(gateway);
OutboundMessage outboundMsg = new OutboundMessage("+9779843669921", "Hello there!");
Service.getInstance().sendMessage(outboundMsg);
} finally {
gateway.stopGateway();
Service.getInstance().removeGateway(gateway);
Service.getInstance().stopService();
}
當我運行我的代碼,我得到以下錯誤:
org.smslib.SMSLibException: No gateways are defined.
at org.smslib.Service.startService_Internal(Service.java:295)
at org.smslib.Service.startService(Service.java:229)
at org.smslib.Service.startService(Service.java:196)
at com.mail.utility.SendSmsUtility.sendSMS(SendSmsUtility.java:10)
at com.mail.action.SendSmsAction.sendSms(SendSmsAction.java:11)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
我已經用addGateway和removeGateway更新了代碼,但是我仍然收到相同的錯誤。 – Sujal
您可以嘗試在'addGateway(網關)'行之後移動'Service.getInstance()。startService();'嗎? – balent
謝謝!這解決了它 – Sujal