简体   繁体   中英

connecting an android device with a java server

I have to create an application in Android the gets from the GPS some data that needs to be stored in a DB at a Java server.

The problem I'm facing is that I don't know what protocol to use for connecting these devices. Some say that I should use TCP/IP .Has anyone any clue why is this better than any other protocol? like http for example or any web service ?

What I need to send between these 2 devices is some objects of this type:

class Date{

String s1;
String s2;
Float f1;
int i1;

}

So, I'm sending on the remote side objects of this type: d1=new Date(); continously. I mean that the data comes from a moving object....which moves about 8 hours a day...So during those 8 hours at intervals of 5-10 minutes I'm sending data!

Which is better and why?:D Thank u!

Which is better and why?

That's still a bit of a subjective question as there could still be a number of ways to do this.

In light of your edited question with the data which needs to be sent and the frequency (5-10 minutes), I'd suggest you look at implementing a simple HTTP service (listener) for the server end and simply pass the data using JSON.

Coding for both of the above is relatively simple.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM