Created
October 23, 2018 17:06
-
-
Save tanerjn/ed1755ad0c03ae14b5544c80031b772e to your computer and use it in GitHub Desktop.
SignalStrengthListener
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| protected class SignalStrengthListener extends PhoneStateListener{ | |
| int signalDBB = 0; | |
| @Override | |
| public void onSignalStrengthsChanged(SignalStrength signalStrength) { | |
| telephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE); | |
| stringSignalStrength = signalStrength.toString(); | |
| parts = stringSignalStrength.split(" "); | |
| if(checkPermission()){ | |
| try{ | |
| cellInfoList = telephonyManager.getAllCellInfo(); | |
| for(CellInfo cellInfo :cellInfoList){ | |
| if(cellInfo instanceof CellInfoLte) { | |
| cellSignalStrength = ((CellInfoLte) cellInfo).getCellSignalStrength(); | |
| signalDBB = cellSignalStrength.getDbm(); | |
| } | |
| } | |
| }catch(Exception ioe){ | |
| ioe.printStackTrace(); | |
| } | |
| } | |
| super.onSignalStrengthsChanged(signalStrength); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment