btn1.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// get Internet status
isInternetPresent = cd.isConnectingToInternet();
// check for Internet status
if (isInternetPresent) {
// Internet Connection is Present
// make HTTP requests
if( SW1_flag == 0 ){
DataCommand = "SW1onPackage";
}
else if(SW1_flag == 1){
DataCommand = "SW1ofPackage";
}
else if(SW1_flag > 1){
SW1_flag = 0;
DataCommand = "SW1onPackage";
}
SW1_flag++;
Thread t = new Thread(new UDP_DataSend());
t.start();
//showAlertDialog(HomeCtrlActivity.this, "Internet Connection",
// "You have Internet connection", true);
} else {
// Internet connection is not present
// Ask user to connect to Internet
showAlertDialog(SWControl.this, "!!! No Internet Connection",
"กรุณาเชื่อมต่อ Internet", false);
}
}
});