Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. Can't initiate network connection in Android extra example
Forum Updated to NodeBB v4.3 + New Features

Can't initiate network connection in Android extra example

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
1 Posts 1 Posters 395 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ajee
    wrote on last edited by ajee
    #1

    Hi,

    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.

    I tried to add some code in NotificationClient.java, as:

    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());
     }
    }
    

    And Then in

    public static void notify(String s)
    {
    ....
    myconnect("10.10.10.1", 80);
    ...
    }

    Of course in the AndroidManifest.xml I added the INTERNET permission and proper "import java.nio.channels.DatagramChannel;" in java file.
    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.

    Should I say Qt can't do the connection in Android extra mode?

    Thanks

    1 Reply Last reply
    0

    • Login

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Get Qt Extensions
    • Unsolved