<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Can&#x27;t initiate network connection in Android extra example]]></title><description><![CDATA[<p dir="auto">Hi,</p>
<p dir="auto">My Qt creator is 4.3.1 based on Qt 5.9, there is an example which interests me, named notification under Qt5.9.1\Examples\Qt-5.9.1\androidextras.</p>
<p dir="auto">I tried to add some code in NotificationClient.java, as:</p>
<pre><code>protected static void myconnect(final String svrAddr, final int port) {
  final SocketAddress serverAddress = new InetSocketAddress(svrAddr, port);
  try {
      // Connect to the server.
      DatagramChannel tunnel = DatagramChannel.open();
      tunnel.connect(serverAddress);
    }catch (IOException e) {
    System.err.println(e.toString());
 }
}
</code></pre>
<p dir="auto">And Then in</p>
<p dir="auto">public static void notify(String s)<br />
{<br />
....<br />
myconnect("10.10.10.1", 80);<br />
...<br />
}</p>
<p dir="auto">Of course in the AndroidManifest.xml I added the INTERNET permission and proper "import java.nio.channels.DatagramChannel;"  in java file.<br />
It compiles successfully, and  I installed the apk in my Android phone, by clicking on the icon, the tcpdump in the server side doesn't receive any packet from the phone.</p>
<p dir="auto">Should I say Qt can't do the connection in Android extra mode?</p>
<p dir="auto">Thanks</p>
]]></description><link>https://forum.qt.io/topic/84558/can-t-initiate-network-connection-in-android-extra-example</link><generator>RSS for Node</generator><lastBuildDate>Mon, 05 Oct 2026 23:14:33 GMT</lastBuildDate><atom:link href="https://forum.qt.io/topic/84558.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 28 Oct 2017 23:18:46 GMT</pubDate><ttl>60</ttl></channel></rss>