I'm coding a java app which consists 2 parts (android and desktop). There will be one desktop and multiple android devices.
I want to;
send data from desktop to android device which I choose,
send data from one of android devices to desktop app only.
I want to send data by using local area network. All devices will be connected same network.
It must work on different places. If I use socket programming (I guess I have to);
is it possible to find lan ip addresses all of android devices which is connected on network?
how can these android devices know the desktop's ip address? Because you know it changes network to network.
How about this:
On all devices, send pings to broadcast address.
Try to connect (TCP) to all clients that answered (not sure if every device will answer to broadcast ping). If connection is established, the other client is one of yours, running your application
Find out whether it's Desktop or Android by the messages itself.
Related
I am working on an app that will act as a dashboard for an electronic card installed in cars and trucks.
I need the application to be able to receive data from this card, so I can display it in various ways on the app.
We chose Wifi for the communication method. To access the card, my app is able to connect to a Wifi network created by it.
I would like to receive JSON sent by the card every second.
I need help on where to start to make the two devices communicate, and what are the good practices on implementing this kind of communication.
The app basically act as a client, and the card as a server.
I found something about sockets, but it seemed to use two Android devices, a server and a client, so I'm kinda stuck here.
I use Android Studio 2.1.2 with the Android APIs ranging from 19 to latest.
One option is to broadcast with UDP the data within the local network. The moment the android device connects to the wifi network it will be in its local network. So the data can be received at the android end with a multicast receiver(check out http://jgroups.org/ ).
Refer example
It may also use the p2p sharing with TCP and bind the device with static IPs for communication. Create a simple socket receiver at the android end and a service at the device end. Depends on the way you choose it.
I am developing an app in which I need to scans WiFi network and display the list of all connected devices.
Allow a use to tap on a device and the app should show all the hardware info of that particular device. Here by hardware I mean - RAM, Storage Media, Storage Capacity, Device Name, Device IP address, etc.
Now this device can be anything like xbox, a laptop with Linux/Windows, mobile phone like iPhone or any Andorid based smart phone or even a printer.
How can I scans WiFi network and query/detect all the devices attached to it?
What are the protocols that I need to use to get list of hardware in a particular device irrespective of the OS running on it?
Check requestPeers of
WifiP2pManager
As per documents it seeks
PeerListListener which returns WifiP2pDeviceList carrying list of WifiP2pDevice which carries deviceAddress, deviceName, primaryDeviceType, secondaryDeviceType, status and other attributes.
Maybe the Network Discovery github project could help you. It lists all users connected to WiFi with IP and MAC addresses and gathers even some information like open ports, device name, ping, etc.
Hope it helps
In my opinion, you can use Wi-Fi Peer-to-Peer
https://developer.android.com/guide/topics/connectivity/wifip2p.html
"Wi-Fi peer-to-peer (P2P) allows Android 4.0 (API level 14) or later devices with the appropriate hardware to connect directly to each other via Wi-Fi without an intermediate access point (Android's Wi-Fi P2P framework complies with the Wi-Fi Alliance's Wi-Fi Directâ„¢ certification program). Using these APIs, you can discover and connect to other devices when each device supports Wi-Fi P2P, then communicate over a speedy connection across distances much longer than a Bluetooth connection. This is useful for applications that share data among users, such as a multiplayer game or a photo sharing application."
Blockquote
I have a question about the p2p functionality of Android OS (4.x and higher). I have a PC program that makes use of the Boost C++ library that can function as a server or as a client. Now i have a Android app that has a server using Java sockets. This program need a accesspoint to connect to each other.
I'm looking for a way to connect the Android server and the PC client program without a accesspoint. After looking around i found out that Android has a p2p library.
Android P2P
As a read it you can only connect two Android devices with each other, my question is if it is possible to use this library to connect the Android device to the PC using wifi p2p? Or if there is a other possiblity? All suggestions are welcome!
Roy, have a look at this: http://en.wikipedia.org/wiki/Wi-Fi_Direct
WiFi P2P is now called WiFi Direct, and it is indeed possible to connect two devices as long as one of the devices supports it. So Android device in P2P mode and a PC without any special configuraiton should work fine. However, the PC can (probably) only connect to one access point at a time, from its perspective the Android device is the access point, it would have to disconnect from its usual access point to connect to the Android device.
Also check out SoftAP.
we have two android device A and B on different network and different IPs, we donot know the phone number of device A.Device B want to connect with device A i only know the application ID of the android Device A and Device installed the app and connected to internet. is there any technique to find device A on network through his application iD in a secured way using java language?
Maybe Google Cloud Messaging?
Hi: I want to implement a http remote control for an Android application: From a browser on a computer in the local area network the application running on the Android device should be controlled.
Are there any recommendation how to implement this? I heard about i-jetty but it is not uncomplex to integrate it into an existing app.
The problem you're going to run into here are:
Android devices are mobile. They do not have a fixed IP address or DNS address. You'd need to implement some sort of discovery service.
Android devices move between networks, and some networks will have NAT. You won't always be able to contact the device.
My advice here would be to use the new Android C2DM service and push a command down to the device telling your application that there's a request waiting. Once the notification arrives, have your application contact a web server at a known address to see what the request actually is.
In other words, you'd be running an intermediary web server that proxies requests on behalf of your Android device.
More information about C2DM can be found here:
http://code.google.com/android/c2dm/