package biz.riopapa.chatread.common;
import android.content.Context;
import android.net.ConnectivityManager;
import android.net.Network;
import android.net.NetworkCapabilities;
import androidx.annotation.NonNull;
public class WifiMonitor {
ConnectivityManager cM = null;
public WifiMonitor (Context context) {
if (cM == null)
cM = context.getSystemService(ConnectivityManager.class);
cM.registerDefaultNetworkCallback(new ConnectivityManager.NetworkCallback() {
@Override
public void onAvailable(@NonNull Network network) {
Network nw = cM.getActiveNetwork();
NetworkCapabilities netCap = cM.getNetworkCapabilities(nw);
if (netCap != null && netCap.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
// String newName = WifiName.get(context);
// if (newName != null && !newName.equals(wifiName)) {
// if (newName.equals("unknown ssid")) {
// new Timer().schedule(new TimerTask() {
// public void run() {
// showWifiName();
// }
// }, 3000);
// } else {
// showWifiName();
// }
// }
}
super.onAvailable(network);
}
private void showWifiName() {
// String wiFi = new WifiName().get(context);
// if (wiFi != null && !wiFi.equals(wifiName)) {
// wifiName = wiFi;
// new ToastText().show(wifiName + "에 연결됨");
// }
}
// @Override
// public void onLost(@NonNull Network network) {
// new SnackBar().show("Wifi Off ",wifiName);
// wifiName = "wiFi";
// super.onLost(network);
// }
});
}
}
'android source ' 카테고리의 다른 글
menu 폭 줄이는 법 (0) | 2024.08.17 |
---|---|
code page 설정하여 파일 읽고 쓰기 (0) | 2024.08.08 |
startActivityForResult deprecated (0) | 2024.05.12 |
image 를 rounding 으로 표시 (0) | 2024.04.28 |
Menu icon 간격 적게 하는 법 (0) | 2024.04.26 |