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.
Related
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.
I'm creating an android app that should communicate with a PC application.
At first, I wrote the PC application as the server side of the connection (on Python),
but for some reasons I want to change it and to make the android app to the server side.
My problem is that the connection should be over the internet.
As I know, the android device (phone) is inside a private network of the cellular company,
which makes a problem to access the device over the internet.
Is there any way that the android device will be accessed directly from the internet?
Yes. IF you have access to TCP/UDP ports (they are not blocked on your private domain),
give a shot to Java Socket Programming.
Whether the server is mobile or PC is totally up to you.
If you need to learn about socket programming, the best place to start is this tutorial on official Oracle documentation website.
This is yet another learning by example tutorial.
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/
I want to create application which I want to use to turn off my computer. I think about connection phone with computer in WIFI. But I don't know how can I send commend to computer and how computer translate this commend and turn off computer. Can you show me the way how can I start and what I should to know to create application like this?
You can achieve that with the client/server paradigm. You'll need to develop an android app that will work as client and a pc app that will work as server.
On the server side you need to wait for two commands:
Discover: Used for the client to know what servers are available
Action: Used to let the server know that it must shutdown itself
I've written an android application which reads database through the content providers. And now I want to display the database in a PC program. How can my PC program get the data gained by the android application? In other words, how to do data exchange between Android and PC via adb?
Thanks in advance!
Go in DDMS perspective, then open the File Explorer, there you can find data directories of the applications and system. Navigate to /data/data/you-package-name/databases, the click the Pull out file from the phone icon, save it wherever you want on your PC.
Android will not let you send files from device to PC using ADB. You can use adb pull to get files, but there isn't a way for the device to push. It would be easier to make a simple TCP client/server setup that would send data via WiFi or 3G. If you really need to use USB, you may be able to use the new USB APIs in Android 3.1.