Android Kotlin Get WiFi IP

val wm = applicationContext.getSystemService(WIFI_SERVICE) as WifiManager
val longIp = wm.connectionInfo.ipAddress.toLong()
val byteIp = BigInteger.valueOf(longIp).toByteArray().reversedArray()
val strIp = InetAddress.getByAddress(byteIp).hostAddress
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />

--

--

--

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

New Feature — Aggressive Enemy

Kotlin Cheatseet — data clas

What Happened to Chat Bubbles / Heads in Android?

How to setup Appwrite.io for Android with Retrofit.

Dependency Injection with Dagger 2 in Android

Jetpack Compose Ep:5 — Divider App

Dagger 2 for feature modules in Android

Supercharging your Android Gradle

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Kevin FOO

Kevin FOO

A software engineer, a rock climbing, inline skating enthusiast, a husband, a father.

More from Medium

My Android Studio Upgrade Debacle

Let's use Android 12, Migration of our Android Apps to Android12 (API 31)

Room Database in Kotlin

Android CodeView: Auto Indentation, Find and replace