I am trying to run an app, it creates a TCP client socket and communicates with a microchip uC device (server) and sends some bytes (using port 1001).
It works flawless in windows10 and using the simulator android studio, but when i download into the smartphone it doesn't work, the TCP connection is never carried out (every time I press a button it tries to connect with timeout of 3000ms).
All permissions are selected (and i see them in the manifest). Maybe is any of my smartphone settings??i can't find it out.
By the way, there is a field in juce for Custom permissions??so you know how to write them??kind of...
android:screenOrientation="landscape"
Best regards and thanks in advance, I am stuck with
Yes, i have tried 1001 and 8000 later with no success (i had already used them successfully in other applications).
The thing is that it works flawless with the simulator and win10, therefore it is driving me nuts. Have checked lot of permissions stuff...but i dont find anything useful.
Do you know if I have to enable any feature/option in the smartphone settings??
Are you using Juce4??or former versions??
By the way, when I use the connect method with POrt, and IP as arguments...if I choose a timeout of 0....or less than <about50-100ms...I can't get the TCP connection. Is not timeout=0 for waiting even a longtime till the connection is established??
Also, I am checking packets with WireShark and the smartphone doesn't send any packet to my server when trying to connect. I seems it even doesn't get to create the socket.
Also I have tried bot armeabiDebug and armeabi-v7aDebug in android studio....have no idea wich the difference is...
I have tried a BQ device (API17) and a Samsung (API10)....no success yet ;(
Hi Jules, wIth newer Android versions...do you mean API 23 and so??I am testing with API10 and API17.
I mean, I think this behaviour should happen to someone else...
I can upload the project /very simple) if anyone want to help, since I am stuck here and I can't get on with my project without network, is very important in mobile apps.
Just as a comment, if useful. I set a global variable (StreamSocket class) to handle the connection. I thought that c# and perhaps JAVA don't use global variables...so I changed this variable to belong to a class (instead of global), just in case to try, but no success either.
Yes - the changes we're working on is just for the newer API versions, IIRC the older ones should still work if you set the permissions in the manifest.
Sorry, really don't understand your point about the global variable, or how that'd relate to java or c#..
I meant that I had a global variable in my project. And I have thought that Java doesn't use global variables, and maybe that was the problem since this global variable was the streamsocket object I was using.
I removed that global, bit it seems that wasn't the problem.
If someone wants to give a hand and replicate this I can send the juce project to see if it is "only" my problem or is compiling related. I would highly appreciate.
I have read in some forums, that is better to make connections in the background since Android is not very keen on allowing synchronous calls in the main thread or somehting like that.
In my app i try to make the connection when I press a button. Should I try to do it in a thread??or any other better way to do something in the background??
Ah yes - absolutely. I think Android prevents you don't any networking on the message thread. If you attempt it, juce would have given you an assertion, but maybe you didn't see that.
Well, I had no more ideas so I sent my APP to a friend, he has got a Samsung with Android 4.4.2 and it works!!!. So....
I have tried with no success in a BQ Android 4.2 (API17) and Samsung Android 3.5(API10). And I am compiling for minimun SDK 10, and I have tried target 11, and 17 (android:targetSdkVersion="x")
Well, after trying and trying lot of different methods (conencting in the main GUI thread, with threads, notifying threads from gui...) I can say that TCPstreaming & UDP Datagram sockets doesn't work for me (My app work as client), at least with Android below v4.4, I don't have more phones to try.
The same APP ith android 4.,4 works flawless, and so does in the Android emulator....I have activated all perssions i could activate and much more.Of course it is not the problem since it works for 4.4
When connecting TCP, the function returns error (i have tried lot of different ways, connecting in a thread, in the main gui process).
Regarding UDP I can open a port, but when trying to broadcast data, the app closes.
I would like to know if anyone else has experienced this, and I have to assume that my android apps only work above 4.4