repalereceivemsg.java
来自「用JAVA实现串口GSM发信息」· Java 代码 · 共 62 行
JAVA
62 行
package com;
import javax.swing.JOptionPane;
public class RepaleReceiveMsg extends Thread {
public void run() {
while (true) {
for (int j = 5 * 60 * 2; j > 0; j--) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println("刷新线程出错!\n");
}
if (GetInput.Ring == true) {
JOptionPane.showMessageDialog(null, "有电话接入...");
boolean ring = true;
int timeout = 30;// 30秒内接电话
while (GetInput.Ring == true) {
if (timeout-- > 0) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
e.printStackTrace();
System.out.println("刷新线程出错!\n");
}
ring = (!ring);
if (ring)
Gsm_Main_Frame.system_call_jTextArea.insert(
"有电话接入...\n", 0);
else
Gsm_Main_Frame.system_call_jTextArea.insert(
"啦~啦~~啦~~~啦...\n", 0);
} else
break;
}
if (timeout < 1) {
Gsm_Main_Frame.system_call_jTextArea.insert(
"1个未接电话!\n", 0);
Gsm_Main_Frame.sendMsg.cancelCall();
}
}
if (GetInput.NewMsgs == true) {
Gsm_Main_Frame.sendMsg.receivesMsg(true);// 获取卡上新信息
GetInput.NewMsgs = false;
}
}
if (Gsm_Main_Frame.sendMsg.testAT()) {//测试通信模块联通性
Gsm_Main_Frame.sendMsg.receivesMsg(false);// 获取卡上已读信息,10分钟刷新一次
Gsm_Main_Frame.sendMsg.receivesMsg(true);// 获取卡上新信息
}else
JOptionPane.showMessageDialog(null, "和通信模块失去联系!");
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?