Connect Android device to host to update data - android

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/

Related

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.

How can i access my localhost XAMP server from my Android mobile?

When i run my project on Emulator than localhost servery is working but when run on real Android phone than localhost server not found. So how can i access my localhost server from my real Android Device. I use XAMP server.
You cannot access localhost from your mobile device because the server is limited to your system only. In order to test the application you have to run the application on emulator so that it could find the server. Although there is a way...if you are creating a whole server that is backend and you have a network to which your mobile and system is connected then you can set your server to listen to a port on that network. I used NodeJs to accomplish that. You can search some tutorials for using NodeJs through which you can access you xampp server. You can also try AdonisJs which is a framework for NodeJs for a better approach. But keep in mind that you need a common network through which your system and your mobile device is connected. It is a bit complicated method but yes that can work. Accessing localhost directly from system to your mobile device is not possible..if you want to avoid learning NodeJs then you'll have to keep using emulator for the testing but learning something new is always amazing. So i would suggest you to learn NodeJs . Anyways you can avoid all the trouble and keep testing your application using your emulator. I hope this answer will help you :)
You should have told which ip you used running on emulator.
Your client on the android device should use the ip of the computer where your server is running on.
Android device and server computer in same WLAN.
If your computer and mobile are connected through same internet line then you can use ip of your computer instead of localhost can do the work.
You cannot access the local host server from a different node eventhough both nodes are connected to same network only way is that change the ip configuration of server to 0.0.0.0: so that you can access the server from any node just by typing the ip of the server followed by port no...

Stream data from Android device to desktop computer when they are connected to different networks (Android WiFi, computer Ethernet)?

I am trying to make an android application that will stream live sensor data (e.g. accelerometer, etc) from my android device to my desktop computer.
My android device is connected to a WiFi network and my desktop computer is connected to a network with an Ethernet cable.
There are android applications available that send data from an android device to a PC via WiFi, but both devices must be connected to the same network.
Is there a way to transfer data if the two devices are connected to different networks?
Thank you!
Due to the fact that nearly every network sits behind a firewall (in most cases your home router/nat-device) you need to implement port-forwarding to access network 2 from network 1.
Another aproach would be to set up a VPN (f.i. with SSH) between the 2 hosts.
If your PC is directly connected to the internet, and has a public ip (that means, if you have NOT a RFC 1918 Adress), then you are able to directly connect to that ip by just entering that ip. If not, you need to implement something to get behind the firewall.
Simple answer; to stream data between a PC and an Android device each residing on different networks you need an intermediate server to pass the data through.
Now, if this just a small app that you are doing for your own purpose I suggest using the free version of Firebase (see https://www.firebase.com/). Their sample application that you'll find there, a simple chat service, does pretty much exactly what you need. Simply let the application on your PC (preferably a web app) read the "messages" that you send from your Android device.

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

How to receive data on my Computer from an android application

I have to connect my Android device to my computer via internet connection. How do i go about doing it?
Create a webservice which the application talks to? ( But how to receive the data from webservice on my computer? )
You are on the right track. Look up REST APIs. You can either run the web service in the cloud somewhere and let both the Android and the PC connect as clients, or you can put a LAMP stack on your PC and run the web server and database right there.
If you allow direct USB connections, then you can also get the data off using ADB or Android File Transfer, without even using your app directly.

Categories

Resources