When I launch the app on my phone the service's onCreate is called 3-4 times in less than a second.
on other hand the oncreate is set to start a thread derived class that prints the network ip of the device on the logcat.
weirdly each call to oncreate gives randomly either the actual ip (192.168.1.xxx) or the loopback (127.0.0.1)
@Override
public void onCreate() {
    super.onCreate();
    TheService=this;
    chargingState = GetChargingState();
    if(mainActivity!=null)
        mainActivity.UpdateDisplay(chargingState);
    IntentFilter ifilter = new IntentFilter(Intent.ACTION_BATTERY_CHANGED);
    registerReceiver(new ChargingStateListener(),ifilter);
    new NetworkHandler().findServer();
}
@Override
public int onStartCommand(Intent intent, int flags, int startId) {
    return START_STICKY;
}
Function to get the IP in the threaded class
    public String GetOwnIPAddress()
    {
        try {
            return InetAddress.getLocalHost().getHostAddress();
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        return null;
    }
 
    