Created
July 28, 2020 14:49
-
-
Save PatilShreyas/e503d4cb5109db030e59f6e6fa54fc9e to your computer and use it in GitHub Desktop.
This file contains 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
fun getCurrentCellInfo(context: Context): List<CellInfo> { | |
val telephonyManager = context.getSystemService(Context.TELEPHONY_SERVICE) as TelephonyManager | |
val allCellInfo = telephonyManager.allCellInfo | |
return allCellInfo.mapNotNull { | |
when (it) { | |
is CellInfoGsm -> getCellInfo(it) | |
is CellInfoWcdma -> getCellInfo(it) | |
is CellInfoLte -> getCellInfo(it) | |
else -> null | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment