简体   繁体   中英

Global counter inside an Android App

So I've recently written an application that calculates tip and I wanted to implement a global (global as in everyone who uses the app) counter for every time a tip is calculated. I have a function that I can easily implement and upload to somewhere to keep a global counter for everyone using an app. The problem is I just don't full understand how I would go about doing this. I'm thinking in terms of this,

If 3G data is on -> upload count to x (server or file online) If 3G data is off -> add a count to file on local device -> if file exists (when 3G is turned back on and app is launched) upload count from file and delete file.

I guess my question would be where would I get some more information on this and/or how would I go about doing something like this?

I appreciate any help, I'm sorry if the question is a bit vague I just can't seem to put a wording on what I wanted to get done.

Thanks a lot,

I think you have to local part right...

If 3G data is on -> upload count to x (server or file online) If 3G data is off -> add a count to file on local device -> if file exists (when 3G is turned back on and app is launched) upload count from file and delete file.

I would probably store that count in a preference instead of a stand alone file for ease but it can go anywhere. As for the server side, a simple web service (I've used PHP) can receive counts and increment a local counter.

However, I am betting there is a nice analytics library like Flurry that you can use that will take care of all of this for you.

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