Skip to content

Instantly share code, notes, and snippets.

@PatilShreyas
Created July 28, 2020 14:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PatilShreyas/e503d4cb5109db030e59f6e6fa54fc9e to your computer and use it in GitHub Desktop.
Save PatilShreyas/e503d4cb5109db030e59f6e6fa54fc9e to your computer and use it in GitHub Desktop.
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