Android Emulator communication from different machines - android

I've referred the developer site and have implemented the following idea that works fine for two emulator instances running on same machine.
•A is you development machine
•B is your first emulator instance, running on A
•C is your second emulator instance, also running on A
and you want to run a server on B, to which C will connect, here is how you could set it up:
1.Set up the server on B, listening to 10.0.2.15:
2.On B's console, set up a redirection from A:localhost: to B:10.0.2.15:
3.On C, have the client connect to 10.0.2.2:
For example, if you wanted to run an HTTP server, you can select as 80 and as 8080:
•B listens on 10.0.2.15:80
•On B's console, issue redir add tcp:8080:80
•C connects to 10.0.2.2:8080
Now for two diffenrent machines I have to make C connect to A's ipaddress:8080. This doesn't work though. What Address should be given in place of 10.0.2.2 for this to work? The IPAddress alone is apparently not sufficient.
I've been stuck with this for abt a week. Any help would be appreciated.

Yes. It's possible. you need server between two emulator. it's not possible to connect two emulator without any intermediate. This role perform by Google App engine``.
Google App Engine is complete, scalable and affordable hosting solution. Using Google App Engine,you can do this. Check this.
App Engine With XMPP:
With the introduction of the XMPP service to App Engine, it's possible to write an App Engine app that communicates with users - or even other applications - over XMPP. XMPP is an instant-messaging protocol, used by Google Talk, Jabber, and other IM networks.
Here one good tutorial of XMPP.
One Example of App Engine..
Hope this will help you.
Update:
java.net.conectExcperion:Connection Rfused : Connect android
This exception occurs when no service listening on the port you are trying to connect.
You also need to understand Emulator Networking

Related

How to connect Android Studio & ESP WROOM 02 (ESP8266)?

First time post here, I am new to programming with android studio. I am not sure if I came to the right place to ask for help. I am not sure what I am trying to do is possible or where to search for tutorials on the subject. I don't have experience with connecting devices over WiFi at all.
Here is what I am trying to do:
I have an App I created with Android Studio, this app has a list of "devices", these devices will control a window over a wifi connection.
In the app, I simply have an "Open" button and a "Close" button for each "device".
I need to be able to show that the 'device' (which is the wifi stepper below) is connected to my app.
I am using the ESP-WROOM-02 (ESP8266) wifi module. Specifically, this wifi-stepper: https://www.crowdsupply.com/good-robotics/wi-fi-stepper
I can give more info or code samples of my project if needed, and any help is much appreciated. I don't know how or where to start.
tldr; I am unsure how to program the connection between the app and the module so that when I press open, the window will open.
Update, As now you say they are both on the same network and the device says "HTTP(S) JSON RESTful interface" you app just needs to make https requests to the ip address of the device.
Docs https://bitbucket.org/aklofas/wifistepper/src/master/documentation/src/interfaces/restful.md
And in Android one method of http requests https://developer.android.com/reference/java/net/HttpURLConnection.html
The device has fairly good documentation of how to set it all up and talk to it via it's various interfaces.

Send data between two Android devices on same network

I'm new to android programming and have a question about networking. I am creating a chess app where two players can play a game against each other on separate devices. My goal is to set this up so it works locally (the devices are near each other or on the same wifi network).
I noticed when trying to work through WiFi P2P (which thoroughly confused me) that the end goal was to get the MAC filter and IP address of the device you are connecting to. If I already have these (i.e. the user inputs them on the client device knowing these values externally) can I simply create the connection without using P2P?
In essence, can I simply start a networked android app with creating and connecting to a serversocket rather than dealing with P2P or NSD?
Thanks and sorry for any confusion,
Scott
you can use the alljyon sdk https://www.alljoyn.org/docs-and-downloads ,i had work with it and it work correctly ,you can find a sample demos one for chat in the same wirless without need the internet connection

Android, HttpListener

I'm fairly new to Android so my question is how do we create an HttpListener on Android device? My task is to create a listener on one android device and request a contact number from second android device & send the data back n forth. Can any one help me?
E.g:
Android Device 1 (Containing Listener)
Android Device 2 (Client)
Requesting Url to Android Device 1: http://192.122.1.2:8888/GetContactDetail?id=2
Response Received: "111111111111"
Any suggestion on how to implement this scenario?
You can try using i-Jetty to run an a webserver on your first device: http://code.google.com/p/i-jetty/
If you have never created a web application before, you can do the development on a laptop and get your second device working with it. Then deploy the application onto i-jetty when its ready.
In practice this won't work since most networks (mobile and wifi) use NAT. NAT prevents inbound connections to device, which basically means that you can not run servers on mobile devices.
Your approach would only work if both devices are on same local network.
Update
You need to embedd a http server into your app: http://tjws.sourceforge.net/
This is what I did, thanks to #elevine suggestion, I was able to do it successfully but as suggested by #Peter Knego the limitations are still there. This will work on LAN without any problem.
Hope this helps someone.
http://codersapprentice.blogspot.com/2011/09/android-integrate-jetty-server-in-my.html

Android App Development - Start a chat with computer device using android phone

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...

Setup simple bluetooth server console?

Hi i wanna work with some bluetooth communication using my Android device.
How can i test bluetooth connections easy?
Let say im creating a simple application that will send the message "Hello World" upon connection. I would like some sort of server application console i could fire up on my iMac and have my android application connect to.
The server application should just be a console or something that displays all the data it receives and maybe a input to back a response.
Is there anykind of program that allow this ?
Or do i really need 2x android devices to create a simple server / client interaction with bluetooth?
this Android Bluetooth Chat App will be good starting point .
you can make this connect to the mac over serial port profile.
The example above is for the latest Android versions (it is possible to accomplish this with 1.x versions of android also, you will have to use the appropriate api that are supported in older android versions also)
For Programming in the Mac refer to This

Categories

Resources