How to use wifi communication for only one app - java

I'm developing android applications which shows real-time data via UDP using WIFI connection on static IP addresses. I'm using AsyncTask class which is executed in one second period.
My problem is that the communication via UDP is interrupted by other applications (for example Facebook - ARP requests) because the WIFI is connected to the IP local device without internet connection.
The interruption is during execution method: socket.receive();
Is there a way to use wifi only for my developed application and has it disabled for other apps?

Related

p2p via socket connection

There are 2 android phones,
They want to communicate directly with P2P via socket connection.
Both phones know each other's IP address'
Both phones are behind different symmetric NATs
You have root access to both phones.
You are allowed to install additional software on the phones
No TURN server should be used in the communication path
how to achieve above scenario

Creating local server on an Android device

I have an idea for an application where one device is a server, and other devices connect to this server.
The clients would send data and call HTTP requests (or whatever is equal to them in this case), and the server would receive the request and act on it.
I understand there is such a thing as Sockets, but does this fulfill my requirement? Will I be able to call requests on the other device?
Example usage: The client clicks the + button, and the server increments the value.
Have a look at P2P, it uses Wifi Direct, so one device can be setup as a host server and the other devices can register to that as clients.
Check out the official documentation.

Frequent BLE disconnection - Android marshmallow+

The Problem:
The bluetooth connection between the android app(GATT client) and two TI boards(CC2640R2F, GATT server) is unstable. When the android app connects to the two boards, the bluetooth connection state of the two boards toggle rapidly between connected and disconnected states. As a result the service discovery process is affected and sometimes there are no GATT characteristics discovered(The GATT service is just empty). The problem occurs with only android devices running marshmallow(6.0+) and above.
This issue also occurs on other third-party apps available in the play store such as BLE scanner, sensorTag and nrf connect running on those android devices.
Fixes attempted on Android side:
The following fixes were attempted on the Android side but these were unsuccessful.
a time delay(tried upto 2000ms) was set between connection successful event and gatt.discoverServices() request.
Have separate device.gattConnect(...) methods for devices below and above marshmallow(6.0). Devices above marshmallow require a TRANSPORT parameter.
Switch connection between the GATT servers to ensure that only one server is connected at a given time.
Created separate Gatt callbacks for the two servers and separate threads for all the operations that took place involving the two servers.
The only fix that was successful is connecting only one server to the client. To connect another server, the app needs to be reopened. If another device is connected at the same time, the issue still occurs.
Data Collected:
The bluetooth sniffer logs were collected from the android side and are attached.
The 'btsnoop_hci_success.log' file deals with the successful BLE connection between an android device(Samsung galaxy s7 edge) running marshmallow(6.0.1) and just one server(a purifier).
The 'btsnoop_hci_fail.log' file deals with the problematic BLE connection between the same android device and two servers(a sensor and a purifier).

Broadcast event when IP changes?

I'm developing an application that is sending data through tcp/ip
I've made my own Name server that the clients register their IP and listening port. All of this is working very well.
Right now the clients send a ping to the server to get the latest IP and updates it if necessary. Since the app is already using quite allot of network I would prefer to minimize it as much as possible.
My question is if the ConnectivityManager (or any other service) sends a broadcast when the IP changes? Or is this not possible for the phone to detect this locally?
For this you need run an service as background with the help of BroadcastReceiver,place the initial IP on DB or some shared preferences,check and update your IP by using background service.Refer the services here http://www.vogella.de/articles/AndroidServices/article.html

2 Way Communication with Android Phone and PC via Internet

I am trying to control a Remote Control Car with an Andriod Phone from my PC (over 3g internet)
I'm planning on using a ioio (Which is just a board that I can plug into a andriod phone via USB)
The part I am working on now is the communication from my PC to my Andriod App. I've never made Andriod apps before and I'm a amateur C# developer.
At the moment I am planning on communicating via UDP as I can create a UDP server/client in Java easy enough. (http://systembash.com/content/a-simple-java-udp-server-and-udp-client/)
However I think this may require a public IP address? Which I will not have either on my client or server.
So for simplicty sake, How would you commucicate over the internet between 2 JAVA applications. If you need to stream video from a camera and simple commands.
You don't necessarily need a public IP, you just need some sort of IP with which one device can send packets to the other. For example, you could connect the phone to your home wifi network, and use the private IPs (typically 192.168.1.x) of the two devices.
If you need the phone to be on 3G, and your PC is behind a NAT router (which is typical), then you'll need to forward a port to your PC — this is a configuration setting on the router — and then have the phone connect to that port on your router's public IP.

Categories

Resources