I have trouble with connecting to a local web interface (192.168.10.13:3671) that are connected to my KNX network from the emulator/phone in Android Studio.
I've tried to connect to the same web interface with a already developed app called KNXwizard and that works, but I see in the code that that app uses AsyncTask.
Always getting this error: Error creating KNXnet/IP tunneling link: tuwien.auto.calimero.KNXException: connecting from /192.168.163.198:3671 to /192.168.10.13:3671: socket failed: EPERM (Operation not permitted)
I've checked this posts
Tried everything there, added permissions to my AndroidManifest.xml, uninstalled, used physical phone etc. But nothing works.
It could be my code, I've tried searching for an alternative method for AsyncTask. So it could be that the code is written wrong. Hope someone could help me out.
MainActivity:
public class MainActivity extends AppCompatActivity {
private static InetSocketAddress local = new InetSocketAddress("192.168.163.198", 3671);
private static InetSocketAddress server = new InetSocketAddress("192.168.10.13",
        KNXnetIPConnection.DEFAULT_PORT);
Button btn;
@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
    btn = (Button)findViewById(R.id.button);
    ExecutorService executorService = Executors.newSingleThreadExecutor();
    btn.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            executorService.execute(new Runnable() {
                @Override
                public void run() {
                    //doInBackground
                    System.out.println("This example establishes a tunneling connection to the KNXnet/IP server " + server);
                    // A KNX tunneling link supports NAT (Network Address Translation) if required.
                    // We also indicate that the KNX installation uses twisted-pair (TP) medium, with TP1 being the most common.
                    // KNXNetworkLink is the base interface implemented by all supported Calimero links to a KNX network.
                    try (KNXNetworkLink knxLink = KNXNetworkLinkIP.newTunnelingLink(local, server, false, TPSettings.TP1)) {
                        System.out.println("Connection established to server " + knxLink.getName());
                        System.out.println("Close connection again");
                    } catch (KNXException | InterruptedException e) {
                        // KNXException: all Calimero-specific checked exceptions are subtypes of KNXException
                        // InterruptedException: longer tasks that might block are interruptible, e.g., connection procedures. In
                        // such case, an instance of InterruptedException is thrown.
                        // If a task got interrupted, Calimero will clean up its internal state and resources accordingly.
                        // Any deviation of such behavior, e.g., where not feasible, is documented in the Calimero API.
                        System.out.println("Error creating KNXnet/IP tunneling link: " + e);
                    }
                }
            });
        }
    });
}
