I'm trying to learn android and for my app i have few questions.
If i type a computer name on the EditText in my android phone, I
should be able to ping the device (So basically i need to first
resolve the ARP to get the mac address of the device which I want to
ping and then send the ping as an ICMP request).
I believe there is some command to retrieve the computer name and
send this ping command, but i would like to do it the hard way so
that i can learn stuffs better - It would be nice if you can show me
some pointers to some tutorial apps and open source code which does
similar tasks.
Once I have identified and connected to the device. I should be able
to start a chat with the device.
Assume the second device is also an android device, how can I
establish basic message sending from one android device to another.
Basically my app will be a client and server (I guess 2 services - service listening to sockets for incoming messages and client can send out messages).
Does anyone know any sample app / tutorials [basically code examples] which does this in android.
To Nr.1
I'm not quite sure why you first need to ping the device, as you could simply try to connect to the given device (using a timeout) and see if it can be connected.
I found some informations on this, here.
To Nr.2
So, if you want your Devices to communicate to each other, you'll want to use Sockets.
But, if your App is only for chatting and you don't need to know if the last send package was successfully send, you could also use UDP instead of TCP (So you don't need your application to run both the Server and the Client-Socket).
Although, all your questions could have been answered by doing a little googleing...
Related
I am using Android studio 2 and java, and i am writing an app that i need to be connected with a piece of hardware through wifi (parrot ar drone 2) and also "trigger" some events (takeoff land etc) through 3g network. I have made a simple app using parrot sdk that do some simple things to my drone successfully . I am facing now the challenge that these simple things i want to be driven through my server (i am thinking of websockets).
So my problem is :
If my device is connected through wifi to the drone, how could i also connect to the internet in order to get "triggered" to run some commands?
I was thinking that would be great if o could connect my android device to the drone and with some way be connected to internet.
After some research i have found that may be this functionality be available to android 6 BUT i have not found any example yet.
Generally i trying to find a solution (software or hardware).
I appreciate a lot any kind of help or suggestion about my problem.
Thx in advance
I don't think it is possible to connect to 2 W-Lan hotspots simultaneously with just one chip. Where did you find that information?
You can set up your Android device as a WiFi hotspot and have your drone connect to the internet via that.
At the same time your app can connect to the drone, assuming your drone has some sort of local server like connection your app connects to.
You can check this in practice quickly by setting up a Wifi hotspot, connecting your drone and then using a ping utility on the phone to make sure you can ping the drone successfully.
If you want to connect from a remote server to the drone then you are dependent on your network allowing inbound connections, which is often not the case. A common workaround is to use some form of mobile push notifications to send a message to your app asking it to contact a server on the internet, which will then tell it what action you want to perform on the drone. In others words:
send message to server on the internet somewhere to tell drone to take off
your server triggers a push notification to the app on the phone
the app contacts the server and asks 'what is the message for me'
the server responds to the app with the 'tell drone to take off' message
the app messages the drone to tell it to take off
I want to develop an android application for LAN calling.My app resembles apps like whatsapp, viber etc, so I googled for the same. What I got from different answer is:
Whenever we install whatsapp, the whatsapp server register our number and contact list. The app continuously pings the server and update its status on server.
When we open the app, it gets the data from server, and if a number is found in contact list, it displays the status of the number and other things.
Whenever we message some one, the message goes to server and stays there until delivered successfully.
For my app the two steps are:
Find all the devices which has my app, their IP and mac address.
When devices are found,allow calling between them.
For step 1, I have two options:
As whatsapp, I can have a server. It registers the info of the mobile phone, whenever the app is installed. The app pings the server and shows its status.
I can use my own network device discovery code. This code scans the network and find the devices.
This step is costly, whole network is flooded with the packets. And also it is quite difficult to write network device discovery code.
For step two, I want to implement client-socket programming and simply connect the microphone of one device to the speaker of another phone. I think it is challenging, but it is possible.
Please help me with network discovery code or the server setup. I am quite familiar with android development, but very novice to networking.
Also how calling is done between these devices?
I have searched for the answer and found the following links: Peer-to-peer SIP call with Android SIP Stack?
how to implement voip in android
VOIP on Android libraries or sample code
I also put a question on quora:
https://www.quora.com/How-can-I-develop-an-app-having-feature-like-whatsapp-calling-in-android
But, still I am stuck at the beginning. Please help me with it.
Not a complete answer yet, but here are the things to look for:
Assuming Java is your language, use Multicast Network discovery in Java using multicasting and https://en.wikipedia.org/wiki/IP_multicast
Calling needs more description. Does the call starts immediately (as soon as the peers detect one-another) ? How does one know the identity information - a number or a username etc. ?
Target:
Sending a file to connected peers. The connected peers should recieve the File without a preinstalled app.
Situation - Question:
I'm writing an app that opens WiFi-direct or a WiFi-Hotspot for other devices. The other devices connect to the device (Main-Device) where the App is installed on. Now the Main-Device should broadcast a file and every device connected to the Main-Device should get a notification, that it could receive a file. But, the other devices should not need an App to receive the file!
Is this possible? Cause all I found till now describes how you can send something from one to an other device if both installed the same app. Using sockets and one device becomes server and the other client.
Reason:
I try to create a game, which just is installed on a Main-Device. Other devices can join the game by connecting over WiFi, then they'll receive a HTML5-file from the Main-Device which they can open in their browser. As soon as they have the HTML5-file they'll be able to interact with the game on the Main-Device.
But I don't want to force everybody who likes to join the game to download the app. Another Point is, if this is possible, I don't need to rewrite the app for other systems. Cause every Smartphone/Tablet has a Browser.
But, the other devices should not need an App to receive the file! Is this possible?
No, it isn't.
I try to create a game, which just is installed on a Main-Device. Other devices can join the game by connecting over WiFi
That, is possible. What you need to do is build a captive portal.
Basically, all DNS names resolve to your server's IP address, and all traffic that would be routed elsewhere is not routed to the internet. How you do this depends on your network setup. There is a lot of software available. I've used Untangle before with decent results: https://www.untangle.com/store/captive-portal.html
I have a small project I am working on and one of the technical problems I am running into is finding a easy way to get one app on one android device to push data to another app on another android device via lan.
I do not want to have to resort to the push API or other similar solutions in case there is no Internet connection.
I was wondering if anyone had any suggestions for this.
Thanks.
You could definitely use Java Sockets. Open a ServerSocket on one device and connect to it using a socket on the other device. You can then send and receive whatever data you want.
I've been looking around for some way to simulate Peer 2 Peer for games on the android and the best way I've been able to come up with is connected an android to a server and then routing through that server. I'm just looking for some thoughts on my way of solving the solution so that you could literally type in someones phone number and try and connect to them.
By use of a service module to check incoming text messages, which would be properly formatted for detection, it would interpret that another phone is trying to request a connection to another one of the androids applications. If the application is found it would then prompt the user as to if they wished to connect to the other person. If yes, their phone would send back a text message to the original phones, which also has the messaging system installed on it, which states it would like to connect and that this is my current IP address. The original phone, or host phone, would then open a connection with the other users phone via the Internet at which point the newly made connection could be used to transfer information back and forth.
Basic list layout
Service module:
- Writes/Receives formatted text messages to alert/verify someone is trying to connect to an application of theirs
- Sender attempts to make a connection with the recipient phone, which takes connection and passes to desired application along with sending back a confirmation package
- On confirmation Sender phone passes connection to original desired application.
Any thoughts, ideas, constructive criticism would be helpful.
* srry for bold, but I hope you understand why.
the best way I've been able to come up with is connected an android to a server and then routing through that server
This is called TURN P2P implementation. You want to read about STUNT implementations too. You'll probably be interested in the JXTA P2P framework.