我有一些java代碼發送短信。
它會在15秒內多次返回一個送貨報告(但有些時候沒有發生)
我想停止那些短信發送功能,如果它沒有給出15秒的發貨報告。
如果你可以,請給出一個類似的示例代碼或
給一些鏈接,我應該閱讀這樣做。
非常感謝你......!退出函數如果不能在30秒內返回值java
`
public String sendTest(String port)
{
modemName = "Huwawi";
bitRate = 115200;
modemPin = "0000";
SMSC = "+94785000008"; try {
OutboundMessage msg;
OutboundNotification outboundNotification = new OutboundNotification();
SerialModemGateway gateway = new SerialModemGateway(id, "COM1", bitRate, modemName, "E17u-1");
gateway.setInbound(true);
gateway.setOutbound(true);
gateway.setSimPin(modemPin);
Service.getInstance().setOutboundMessageNotification(outboundNotification);
Service.getInstance().addGateway(gateway);
Service.getInstance().startService();
msg = new OutboundMessage("+94710433607", "test successful !");
Service.getInstance().sendMessage(msg);
OutboundMessage.MessageStatuses status = msg.getMessageStatus();
System.out.println(msg.getMessageStatus());
Service.getInstance().stopService();
Service.getInstance().removeGateway(gateway);
} catch (Exception ex) {
if (ex.getStackTrace()[2].getLineNumber() == 189) {
JOptionPane.showMessageDialog(null,
"Port currently owned by usb Modem's application. \n Please close it & run the programm again.",
"Port Exception",
JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
} else {
JOptionPane.showMessageDialog(null,
ex.getMessage(),
"Sending faile",
JOptionPane.ERROR_MESSAGE);
ex.printStackTrace();
}
}return port;
}
'
如果我給的代碼是從
Service.getInstance().startService();
卡住如果我給傳遞報告之前15秒獲得正確的端口號的錯誤的端口號。
如果我提供錯誤的端口號,代碼不會給出或返回任何值。 如果代碼在15秒內沒有返回值,我知道端口號是錯誤的。
所以我想幫助自動關閉功能,如果它不在15秒內返回一個值。
再次感謝...!
所以ü[R要求我們做烏爾功課? – Bikku
告訴你迄今爲止所嘗試過的。嘗試一下,如果你遇到麻煩,那麼有很多可以幫助你。但關鍵是你應該先嚐試。 – hagrawal
它卡在哪裏?在Java代碼中,從描述中,我懷疑?在運行SQL時,那麼哪個數據庫?主機上的外部命令?沒有足夠的信息來回答。 – YoYo