Problem with socket using TCP/IP protocol and mkr1000 as access point

Good Morning,
I am developing an Android app to control an Arduino MKR1000 board, by communicating over the TCP/IP networking protocol. The Arduino works as an Access Point and send data, when there is a client available. My Android app manage to connect to Arduino's WiFi shield, but when I try to connect the Socket on the specified port number, where the server is listening (on Arduino side) and on the named host, I get an Exception (in Android):

W/System.err: java.net.ConnectException: Connection refused
 W/System.err:     at java.net.PlainSocketImpl.socketConnect(Native Method)
     at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:334)
   at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:196)
    at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:178)
 at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:356)
  at java.net.Socket.connect(Socket.java:586)
    at java.net.Socket.connect(Socket.java:535)
    at java.net.Socket.<init>(Socket.java:427)
     at java.net.Socket.<init>(Socket.java:243)

Looking on the Internet, it happens when there is no server listening. Besides when I turn off the wifi on my moblie, this doesn't result as disconnected, in the Arduino Serial monitor (see the code below) and when I turn on the wifi and try to connect to the Access Point, my mobile doen't result as connected, but the wifi status remains in listening mode.
So the Arduino board doesn't work as it should be, but I can't figure out why.
I found a similar question:
https://forum.arduino.cc/index.php?topic=484714.0
but it didn't solve the problem.

I would be grateful for any ideas!

Thanks.

My Arduino code:

#include <WiFi101.h> 
#include <Arduino.h>

char apssid[] = "WifiMotors"; 

  
int status = WL_IDLE_STATUS; 

unsigned int localport = 2390;   

unsigned long ms=1000;
unsigned long start=0;
unsigned long end=0;
String stringa;
char str;

//Server in ascolto su porta 2390
WiFiServer server(localport);

WiFiClient client;  

 void setup() { 
  
   Serial.begin(9600); 
     
  #ifdef DEBUG
while (!Serial) {
  //   wait for serial port to connect. Needed for native USB port only
}

#endif

   if (WiFi.status() == WL_NO_SHIELD) 
   { 
     Log("WiFi shield non è presente"); 
     
   } 

 WiFi.config(IPAddress(192, 168, 1, 7)); 


  Log("Creating access point named: "); 
  Log(apssid); 
  
  if (WiFi.beginAP(apssid) != WL_AP_LISTENING) { 
   Log("Creating access point failed"); 
 
  }else{
    Log("Creating access point success"); 
    } 

  
   delay(1000);

   //server sta sempre in ascolto
    server.begin();
         
   #ifdef DEBUG
  printWiFiStatus(); 
  #endif
 
    analogWriteResolution(10);

   
 }
 
 
  
 
 void loop() {
   
 if (status != WiFi.status()) {
     //it has changed update the variable
    status = WiFi.status();
     if (status == WL_AP_CONNECTED) 
     {
      byte remoteMac[6];
      
      WiFi.APClientMacAddress(remoteMac);

      // a device has connected to the AP
      String line="Device connected to AP, MAC address: "+
     
      String(remoteMac[5], HEX)+
      String(":")+
      String(remoteMac[4], HEX)+
      String(":")+
      String(remoteMac[3], HEX)+
      String(":")+
      String(remoteMac[2], HEX)+
      String(":")+
      String(remoteMac[1], HEX)+
      String(":")+
      String(remoteMac[0], HEX);
      Log(line);
      
    }
    else if(status == WL_DISCONNECTED) 
    {
      // a device has disconnected from the AP, and we are back in listening mode
    
      Log("Device disconnected from AP");
        
    }
 }

//Se un client è inizializzato, 
//oppure il server ne restiruisce uno in coda,
//e  il client è connesso

 if((client || ( client= server.available())) && (client.connected()))
 {
  Log("hello client");

     //se c'è un dato da leggere

     if(client.available())
     {
//do stuff
           
}

     if((end-start)>=ms)
     {
        start=end;
        int value = analogRead(A3);
        client.println(value);
        Log(String(value));
 
        }
 }

 end=micros(); //tempo che scorre

   
 }

 void Log(String s){  
  
  #ifdef DEBUG
  Serial.println(s);

  #endif
  
  }
 
 
 void printWiFiStatus() {
  
  // print the SSID of the network you're attached to:
  Serial.print("SSID: ");
  Serial.println(WiFi.SSID());

  // print your WiFi shield's IP address:
   
IPAddress ip = WiFi.localIP();
  Serial.print("IP Address: ");
  Serial.println(ip);

  // print the received signal strength:
  long rssi = WiFi.RSSI();
  Serial.print("signal strength (RSSI):");
  Serial.print(rssi);
  Serial.println(" dBm");
  // print where to go in a browser:
  Serial.print("To see this page in action, open a browser to http://");
  Serial.println(ip);
}

My Android code:

 try {

                    remoto = InetAddress.getByName("192.168.1.7");
                    mSocket = new Socket(remoto, 2390);
                } catch (IOException e) {
                    e.printStackTrace();
                    
                }

if you use wireshark to monitor traffic can you see the packets?
do you need to open the firewall on the android to allow outgoing TCP connections?