我有一个使用以下代码注册观察者的活动
活动:
//Register for network status updates
NetworkStatus networkStatus = new NetworkStatus(this);
networkStatus.addObserver(new OfflineActivity());
Thread thread = new Thread(networkStatus);
thread.run();
主题:
@Override
public void run() {
for(;;) {
Log.d("NetworkStatus", "Checking Network Status");
if(isConnectedToInternet(context)){
notifyObservers();
Log.d("NetworkStatus", "Network Connection is established");
}
else {
Log.d("NetworkStatus", "Not connected to network");
}
}
}
当我单击活动时,程序变得无响应..有什么想法吗?