0
내 응용 프로그램에서 나는 거기에 연결 여부를 결정할 수 있지만, 그 응용 프로그램 자체가 5 번 다시 연결하려고 할 때마다, 그리고 다시 연결할 때까지의 간격을 늘리 길 원하지만, 그렇지 않습니다. 일하면서, 그는 즉각적인 반응을 보냅니다. 당신은 잠시 동안 잠 새로운 스레드를 생성안드로이드 다시 연결 인터넷 문제
public class ReestablishConnection {
Application APP = new Application();
boolean status;
int reconnectInterval = 1000;
int i;
public boolean reconnect(String URL){
Thread timer = new Thread(){
public void run(){
for(i=1;i<6;i++){
if(APP.testConnection(APP.defaultUrl()) == 0){
status = false;
}else if(APP.testConnection(APP.defaultUrl()) == 1){
status = true;
}
try {
sleep(reconnectInterval * i);
} catch (InterruptedException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
};
return status;
}
}