need help to make client-server app in eclipse - android

I need a client server example and steps to create it on eclipse,
I am using eclipse and i have tomcat7.0 and wamp server in my PC,
I have a device (samsung mobile) that i want to use as server/client and emulator(AVD) as client / server,
How to create a server side app in eclipse? please explain with all steps,
How test / run app?

How are the client and the server going to communicate? Through Wifi/Bluetooth/Using http?The only true client server model that comes in to my mind is having let's say php pages that you are going to send HttpRequests (check this for an example) from your android application and the server will handle. In the case of bluetooth wifi you just have to open a socket and send the data. It must be noted that your pc and the emulator have different ip address range, thus in case of TCP/IP socket it is quite tricky (although I think it is possible) to establish a communication between your android phone and an Android virtual device. I hope I didn't misunderstood anything.

Related

Accessing an API on an Android device over the Internet

I have a use-case for Android devices that I can't seem to wrap my head around. The gist of it is I want to be able to send an API command from my server to my Android app over the Internet. The solution already works if my server application is hosted on the LAN: each Android device has an IP, and I send the command to each device's IP. What if my server is on the cloud? Is there a way for my server application to connect to my Android device directly without the need for a local server?
In this use-case, the Android devices are connected to network through either WiFi or ethernet, and the network has internet access.
Any suggestion would be wonderful, thank you!
When you are in local area network, both your server and client (Android device) are assigned with virtual IPs so there is no problem with see each other.
But when your move your server application to cloud, it cannot see your Android device anymore since your device is hidden by NAT. Only the gateway(your wifi router) IP can be seen by the server.
Some ways you can try:
Assign a static IP for your Android device, and configure your gateway to make a port forwarding to redirect the network traffic to your device. Then your server can see your device by sending to your-gateway-ip:port. But this is usually not a preferred way, unless you can always have full control of the client side network environment.
Change the application protocol to something like MQTT. In such case both your server and client can connect to this "broker" server so exchanging data is possible regardless of your client is under NAT or not. However, you may need to setup this extra broker server.
Find other third party notification services to do this server to client communication, such as Google Firebase.

Is it possible for android watch to connect a server (with IP and port) directly (without phone)?

I'm making client program for android watch (of android wear OS) using socket connection.
In my server & client program for general computer, I'm trying to change the client part to that for android watch. But, I cannot find a sample code related to socket connection for android watch (of android wear OS).
I learned that android watch usually connect google cloud server through phone, and it is possible to directly connect via WiFi without phone. (https://developer.android.com/training/wearables/data-layer) Those are related to Wearable Data Layer API.
My questions are as follows. I'm not sure that android watch as client directly connects our server (with IP address and port number). If possible, could you give some sample codes for socket connection or URL for the codes? (I googled the related codes but I couldn't find them.)
I hope your many comments and welcome any comment. Thanks in advance.
Depending on the hardware you may or may not be able to connect directly (i.e. without relying on a phone) to your server.
For supported devices you can setup a network connection using the ConnectivityManager as described in this guide on Google's developer website.
Once you have established a network connection you should be able to connect to your server.

Testing the server side code before deploying

I need to send an image file from the mobile to the server(where the server will save it to the hard disk). I have wrote both the android mobile part and the server side. I need to test the code before deploying to the server. Will the code work if I connect the mobile to the WI-Fi network through which I can have a LAN connection to the system? Is there any way I can test the code with out using a WI-Fi connection(ie Connecting phone to the system via the usb cable and then forming a LAN or something)? Please voice your valuable opinion in these stuff.
When I was testing my server-side I didn't find any other way rather than connecting via wifi, this way it was working just fine (in your code you need to use ipv4, not localhost, just as reminder). I'm not good with network stuff, but I don't think it's possible using usb to create some kind of LAN.
Have u tried from emulator? How to connect to my http://localhost web server from Android Emulator in Eclipse

Connect Android device to host to update data

I'm writing an Android application for Hotel Management. That each employee has own tablet running Android OS. this app sometimes will send data to host (that the room has been booked) or host will send data to client (about new condition of other rooms).
Host can be an another Android smartphone or a PC, and those device will connect together through same wifi network.
I don't know which way is easier (using smartphone for host or PC for host). If using PC, I decide that PC will have local server running database, and each tablet will connect to this server and update data from database. Does this easy to implement ?
Please help me figure out those problems. thanks :)
You want to use PC/Server for the host so you can run a proper RDBMS.
There are tons of examples available for creating Android apps that talk to a variety of RDBMS systems. On your server you'll run an interpreter (PHP, ASP.NET, Node) and your Android app will connect to this over the Wifi network using http.
See example here:
http://www.androidhive.info/2012/01/android-login-and-registration-with-php-mysql-and-sqlite/

How do I get my Android app to communicate with the server over a VPN?

I have an android application that talks to a server app running on grails (Groovy on Grails).
Android app basically establishes a connection with this address:
url="http://192.168.2.53:8080/tma/majBtm/androidToDesktop";
It all works fine when both the server and the android phone are connected in the same lan network.
Now the problem arises when I want the phone to talk to the server while the phone is outside the local network (I need it to use edge).
I came across VPN networks which I think might help me out. (the server has dynamic IP)
So what i did was go to dyndns.com and created a new hostname and have the app successfully run on the server. The host I created was - tmagrails.dyndns.com
How do I make my phone connect to this network? What changes am I supposed to make in order to get things working?
Also, I really want to know if this is the right approach. If not, is there any way to get things going for me?
Please advice.
First you need to set up port forwarding so that port 8080 is forwarded to your 192.168.2.53 ip address. A google search on your router model should tell you how to do this. If you want to make your app more secure you will also need to look at SSL and TLS While this won't garantee your app is secure it will stop the network traffic to your app being easily read if you were to access it from an open wifi hotspot.

Categories

Resources