Android application can't connect to APN

123 views Asked by At

I'm developping an android application that need internet connection in order to work. The application works perfectly when connected to wifi, but not when using mobile data connection. The mobile data connection is an APN with proxy. I can navigate correctly with the browser, but not from inside the app. (And also the email program).

The mobile data configuration has no restriction for all the apps.

Im really embarrassed.

Any help would be very appreciated!

I can make ping at an address within the app, but when I try to get a certificated from a host

using the code:

int port = 443;

        //create custom trust manager to ignore trust paths
        trm = new X509TrustManager() {
            public X509Certificate[] getAcceptedIssuers() {
                return null;
            }

            public void checkClientTrusted(X509Certificate[] certs, String authType) {
            }

            public void checkServerTrusted(X509Certificate[] certs, String authType) {
            }
        };

        sc = SSLContext.getInstance("SSL");
        sc.init(null, new TrustManager[] { trm }, null);
        factory =sc.getSocketFactory();
        socket =(SSLSocket)factory.createSocket(hostName, port); // <------- HERE IS WHERE THE APP CRASHES
        socket.startHandshake();
        session = socket.getSession();
        servercerts = session.getPeerCertificates();

it's when it returns an error:

java.net.UnknownHostException: Unable to resolve host "server1.demo.test": No address associated with hostname
0

There are 0 answers