Android apps: sharing simple data between phones
Here's what I want to do: I'm trying to make an Android 开发者_如何学运维app that manages a carpool. What I am stuck on is how to have the data about who is riding shared across everyone's phone.
I've seen many topics involving sharing a large amount of data between phones and needing either to setup a server or use the C2DM framework. I'm looking for something simpler. Is there a way to have one phone send a message to the others in the carpool so that only the application will detect it? I don't want to inundate everyone's text message inbox so I want to avoid SMS.
There are a bunch of threads discussing one solution, which is to use Google's Android Cloud To Device Messaging (C2DM).
Here are the links:
- Push Notifications in Android Platform
- Does Android support near real time push notification?
- http://blog.boxedice.com/2010/10/07/android-push-notifications-tutorial/
Re: "setup a server or use the C2DM framework" - those two are unfortunately not exclusive. Unfortunately, you will almost certainly have to set up a server somewhere to keep track of the comms (you can't rely on either the sender or recipient being online at the same time). After you've got that running, it's a matter of whether you use c2dm or not.
As long as the majority of your userbase is 2.2 or above, I would strongly recommend c2dm. If you have a significant below 2.2, then you could use a message-over-google-talk type strategy - but that could get messy depending on the complexity of your messages.
Please don't consider auto-sending SMSs from your app. It may seem like a reasonable thing to do, but I don't think your users would prefer this option (just from my research into a similar kind of message transfer mechanism for my game).
It seems anyhow that you should rely on a server, as Richard said. For logging and reliability issues, ain't reaching one fixed point easier than reaching every mobile member of your pool ? espec. if you don't want to spam their SMS inbox...
you could try to format your data such as the SMS manager lets your app do the rest, by sending a particular sequence at the beginning of your messages and delete them afterwards?
You could imagine use a single check-in script to be called from your droids to track the location of you cars (using a simple HTTP request and POST Data), and at every update of the position of a car, have the server send a push notification to your fleet.
The strength of the C2DM topics is that it begins to have a well dressed documentation and community. Yet remember it is still in beta.
There is a startup mCruiseOn that solves just this problem. I cant imagine you doing this peer to peer, since there has to be a central place (server), where every device gets routed only those carpool's that are relevant to their own need.
We are using mCruiseOn api's for cab booking. Soon we will have a product around them.
My honest opinion, use a existing framework, the only one I know is mCruiseOn.
精彩评论