[SOLUTION] How to find out my IP address in smartphone WIFI status

How to find out my IP address in smartphone WIFI status

Share the source code.

import android.net.wifi.WifiManager;
import android.content.Intent;
import android.app.Activity;
import android.content.Context;
import android.net.wifi.WifiInfo;
Activity act;
Context cnt;
boolean toggle;
WifiManager wifi;

void setup() {

fullScreen();

background(0, 0, 100);

act = this.getActivity();
cnt = act.getApplicationContext();
wifi = (WifiManager) cnt.getApplicationContext().getSystemService(Context.WIFI_SERVICE);

WifiInfo wifiInfo = wifi.getConnectionInfo();
int ipAddress = wifiInfo.getIpAddress();
String ipString = String.format(ā€œ%d.%d.%d.%dā€,(ipAddress & 0xff), (ipAddress >> 8 & 0xff), (ipAddress >> 16 & 0xff), (ipAddress >> 24 & 0xff));
println(ipAddress);
println(ipString);

}

void draw() {
}