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.
Related
I want to connect my Android App to the back-end. The aim of the project is to filter spam messages. So the app receives SMSs and then should forward it to server for spam filtering which uses machine learning. Now, the thing is we have a python program for machine learning but I don't know how to connect these two things - the Android app and the python program. Need guidance on how the app can send data(sms) and receive response(whether spam of not) to and from the server-side.
A common approach is to connect your client with a web backend that offers a web API (might be a REST API).
Here is a short overview over this topic: https://www.webiotic.com/api-for-mobile-apps/
What you need is a web server which can receive web calls and send back information. A web server in this sense is just a program which listens to incoming HTTP calls.
In your case, this might look like this:
The server is programmed to listen to web calls with the HTTP method POST on the route /checkMessage
It expects the message data in a certain format
For example in JSON with this content: {"message":"Your actual SMS message"}
the server checks its database or triggers a ML job
server returns a result in a specified format. For example this JSON: {"isSpam":true}
Your app then needs to send a POST call to https://www.[YOUR_URL]/checkMessage with the specified data and wait for a response
There are libraries for android which help you with that like Retrofit or OKHttp
As for which technology to use: It's up to you. You can create a web backend in pretty much every language. In your case, you should check out which Python libraries are available to listen to HTTP connections.
Keep in mind that if your app can publicly access your backend, then everybody else can as well. You will want to add some kind of authentication as well.
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 have an Android app with some data (consisting in latitude and longitude) and a RAILS web service with a MySQL database... I want to know how to send this data to my database
You need an web server with logic implementation to accept/update/delete data from mysql server either by using Java/PHP etc...You need to specify internet permission in your manifest file. And follow the link below for more detail how to make PHP server sends data to an Android device
Rails exposes REST APIs that you can use to send data to your server. There should be an api that accepts post requests and updates the data on your web application's database. Ask your rails developer for the url.
Make a REST post/put call to your webservice.You can use Android httpclient to make a connection. The api is available here
http://developer.android.com/reference/android/net/http/AndroidHttpClient.html
As always, don't forget to turn on your internet permission and perform your network tasking within AsyncTask or another thread to prevent UI thread blocking.
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.
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.