I want to send image and text data from Android phone to a Server. i am new plz suggest me the best and easy way to do this task. Server is running a java web service and i will be getting the data from server and also sending the data to server. Thanks
As your server is already there, you will have to use protocol it can uderstand - also SOAP, REST or whatever it uses. So no choice for you.
If you are deigning client-server interacton with android application, you may consider network socket communuication which has less overhead as webservices.
Related
I wanted a background service that listens for data from XAMPP server. I don't want the app to make HTTP requests to check data in the server periodically, instead i want to have an event in the app that gets invoked along the data from the server. This question may seem vague but can anyone suggest me from where to start?? I will be very thankful.
You can use Node.js with express and socket.io, its easy to install and for usage. But also you can use online socket services. And for MySQL querys you can use Sequelize.
I am trying to learn to implement android apps to get news, promotion message, and calendar from server. What is the best and easy way to communicate with database server? using JDBC or other methods?
Thanks
Using JDBC?:
In the words of Commonsware:
Never never never use a database driver across an Internet connection,
for any database, for any platform, for any client, anywhere. That
goes double for mobile. Database drivers are designed for LAN
operations and are not designed for flaky/intermittent connections or
high latency.
On the client side (Android app), you can use SQLite to store data locally. It might not be necessary at all actually. For instance, it can be used for offline features, search, etc. For client-side, read up on this simple post
On the server side (whatever server side technology you know or want to learn), you can use whatever language, whatever database on whatever server OS you want. This part is commonly called the back-end, which will store your data while your app communicate with it through HTTP.
You can use json to parse data between server and the android device. In the server you can use jdbc with json if you are using servlets in the server.
To communicate between a server and an android device you can use JASON. See following links for some help.
http://www.androidhive.info/2012/01/android-json-parsing-tutorial/
https://www.learn2crack.com/2013/10/android-asynctask-json-parsing-example.html
https://www.learn2crack.com/2013/10/android-json-parsing-url-example.html
Also in the device to deal with data within the device you can use SQLite. And in the server you can use jdbc if you are using servelets.
To communicate with Database server You should use web service API such REST , soap
I created a small app and with this app I want to send the data (over wifi or bluetooth) to a PC/server.
I am thinking of creating a webservice that will run on the PC and will be listening constantly to any incoming client requests.
Once it receives request from client, the data transfer takes place.And after the webservice receives the data it should automatically open an application/GUI window showing the data received.
My question is Can I create a webservice using TCP/IP in JAVA and have it constantly run in background and listening to client request?
Also how do I start a GUI as soon as the webservice detects a client request and receives the data?
Use SQL Server to manage the data on your desktop and create a web-service in .NET on Visual Studio.
Then connect to the web-service in your application and set/get data from the DB, using web-services.
Links which might be useful :
How to make a web-service in .NET (does not include the implementation in Android) : http://srikanthtechnologies.com/blog/dotnet/wsdaljava.aspx
How to connect your service with Android :
http://seesharpgears.blogspot.in/2010/11/basic-ksoap-android-tutorial.html
http://www.codeproject.com/Articles/304302/Calling-Asp-Net-Webservice-ASMX-From-an-Android-Ap
http://adrianandroid.blogspot.in/2012/05/access-c-net-web-service-in.html
the best way is to create a web service and connect your application to the web service, you can use the tool http://www.wsdl2code.com that create all the needed code for connecting and parsing the data :)
I recommend to use WS on the server-side and you can use Ksoap android library on the client-side. Create a background thread which updates the UI with the new data with. Use AsyncTask, Loader or Handler which is fit for your solution. (Read the official reference for more info).
you can easily achieve this by creating an end-points/routes using node.js or php then host it on the cloud. I think I like firebase for hosting for now, u might wonna try that it really cool. after creating those endpoint which will be connected to ur database then u use http get or post request depending on what u want from ur database in ur mobile app.
if u are creating for android use Retrofit for http connection.
I want to access an online MySQL database in order to retrieve and manipulate data. I read that the best way would be implementing an own web-service, which returns XML and then parse it in Android, is it right?
Does anybody have a basic tutorial?
Since you want to access a remote server which has your DB and other stuff.
You basically have two options.
1 - ) Either directly access your server via sockets etc.
2 - ) Or create a web service which will connect your server to the outside. ( I.e : Android Client,iOs client etc.)
The best practice is to create a web service and then consume it in your Android application.
Check these for consuming XML in Android.
http://www.ibm.com/developerworks/opensource/library/x-android/
http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/
Check these for creating web services on server side. (Stack independent)
http://davidwalsh.name/web-service-php-mysql-xml-json (PHP)
http://www.roseindia.net/webservices/buildingsimplewebservice.shtml (Java)
http://www.codeguru.com/csharp/csharp/cs_webservices/article.php/c19391/Creating-a-NET-Web-Service.htm (.NET)
And so on there are a lot of stacks to create web services.
Again, Webservice is the best approach. But you have to take decision based on the amount of the data being retrieved from the server and how often the transaction needs to be synchnorized with the server.
What Arvind was trying to explain you, incase if the volume of data is too large to download via webservice then you probably need to think of some middle tier that will convert he data to json and send it to your device. The reason, if you are transmitting the 1k of soap response over the air, for the same response, if you are transmitting thro json, it could be 100k or 200k or 300k depends. That way you can save the transmission cost over the net and turnaround time is quicker .
I have an app in android,a kind of client-server in which the client has stored some gps data in Sqlite database and once connected with server it delivers it that data which at its turn stores it in it's own database for future manipulation!
Now the problem is that I have to create a server that accepts multiple clients and I cannot find a decent example in this way.I'm not using no services in combination with it!
Both my client and server are on android!!!!
I have already did the connection between client and server,but only with one thread(I mean my server can accept only one client at this moment!)
Is this suitable?
How to implement simple threading with a fixed number of worker threads
Thank u in advance!
If server is Microsoft based, .net web service can be used that can be accessible from multiple Android clients and work with database.
Your server is not on the Android device I guess, so I don't think the question is android related.
Check out this example of multithreaded server in Java and this one as well.
To communicate with database, see the Java JDBC tutorial.
Those examples are in Java, because that's what I am used to, but any other language will fit as well.
A simple POST request from the client to the server should be good enough. Encode the data in a suitable format (JSON/XML) and send it as a POST HTTP request.
I don't understand why you want to write your own server. I would just use a PHP/Python script running with Apache to receive the POST request and store the data in a database (MySQL, PostGre).
On your Android device, you should put all your code in an AsyncTask. Android uses the standard Apache libraries to make the HTTP request.