opt traffic light panel
This commit is contained in:
@@ -3,6 +3,10 @@ package com.mogo.utils;
|
||||
import android.content.Context;
|
||||
import android.net.ConnectivityManager;
|
||||
import android.net.NetworkInfo;
|
||||
import android.telephony.PhoneStateListener;
|
||||
import android.telephony.SignalStrength;
|
||||
import android.telephony.TelephonyManager;
|
||||
|
||||
import androidx.annotation.Nullable;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -107,4 +111,17 @@ public class NetworkUtils {
|
||||
return matcher.matches();
|
||||
}
|
||||
|
||||
public static int netStrengthLevel = 0;
|
||||
|
||||
public static void listenNetStrength(Context context) {
|
||||
TelephonyManager manager = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
|
||||
manager.listen(new PhoneStateListener() {
|
||||
@Override
|
||||
public void onSignalStrengthsChanged(SignalStrength signalStrength) {
|
||||
super.onSignalStrengthsChanged(signalStrength);
|
||||
netStrengthLevel = signalStrength.getLevel();
|
||||
}
|
||||
}, PhoneStateListener.LISTEN_SIGNAL_STRENGTHS);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user