NetCounter is a network traffic counter for the Android platform. As a big Unix/Linux fan, I like the K.I.S.S. principle. So this application will not integrate tons of features but will (try) to display your network traffic consumption in a simple and nice manner.
I wrote this application because I need it. I have only 250 MB included in my contract so I have to take care of my bandwidth usage. As Android does not include such a counter, I decided to write a simple application which will show me my current bandwidth usage.
This is my first Android application. I still have a lot of things to learn about Android and I will improve and fix bugs in NetCounter as I am getting more familiar with the framework.
- Open-source software.
- Network traffic counter for both EDGE/3G and Wi-Fi.
- Available in English, German, Czech, Italian, French, Russian, Spanish and more.
- Data are persisted.
- Dynamic counters that can be added, modified and removed. "Total", "Last 30 days", "Last 7 days", "Today", "Yesterday", "Weekly", "Monthly" and more are available.
- Alerts on a counter basis if limit exceeded.
- Starts automatically if you restart your phone.
- Export/Import data to/from the SD card (CSV format).
- Fixed crash (ArrayIndexOutOfBoundsException) with Swedish locale. Thanks to Fredrik Premler and risbert.
- Improved Dutch translation. Thanks to Bram Schoenmakers.
- Updated Swedish translation. Thanks to Tibor Baranyi.
- Network interfaces should be automatically discovered now. Should work for most devices. Contact me if yours does not. Thanks to everyone who submitted a patch to support their devices (Matti, Jon, Tristan, Samuel, Bram, Marco, Thilo and many others).
- Hopefully fixed CSV export issue on newer version of the SDK.
- Added support for Samsung I5700 (Spica). Thanks to everyone who provided the required informations.
- Added support for Google Nexus One (passion).
- Updated Catalan translation. Thanks to Joan Montané.
- Added Swedish translation. Thanks to Tibor Baranyi.
- Added "last month" counter as per users request.
- Motorola Droid support. Thanks to everyone who provided the required informations.
- Accept all screen resolutions. Should work on HTC Tattoo.
- Switched to SDK 1.6 (4) but minimal requirement is still SDK 1.5 (3).
- NetCounter now requires Android 1.5. SDK version 3.
- Added BarGraphActivity. Uses a modified version of AChartEngine (Apache 2 license). This is still experimental.
- Added debug option. Show some debug information in the notification area.
- Added Russian translation. Thanks to Dmitry Kutsenko.
- Hopefully fixed the negative value bug. Thanks to Erwin Betschart and Stavros Kafouros.
- Added aTrackDog support.
- Added What's New dialog on first start of a new release/new install.
- Added support for T-Mobile Pulse (Huawei U8220).
- Many bug fixes and improvements.
- Fixed NPE. Thanks to Julien Sansonnens.
- Added import feature. Can import files created with the export function.
- Force an update of the interface if the day changed. Thanks to Kimmo Koskinen for the report.
- Added start and end dates in the detail dialogs. Thanks to Darren Krusi for the idea.
- Added preference screen.
- Added slow WiFi option. If enabled, only update every hour (instead of 30 seconds) while in background.
- Hopefully a better (correct) implementation of WakeLock/Alarm. Thanks to The Busy Coder's Guide to Advanced Android Development by Mark Murphy.
- Added required permission RECEIVE_BOOT_COMPLETED.
- Added view wrappers as described in The Busy Coder's Guide to Android Development by Mark L. Murphy.
- Fixed Italian translation. Thanks to Gianfilippo Grignola.
- Added Catalan translation. Thanks to Joan Montané.
- Added devices support. Interfaces do not seem to be named equally on all devices.
- Only update the interface if the data changed.
- Update even if the interface is down. Should show consistent data for WiFi after a new day even if the interface is down.
- Added Dutch translation. Many thanks to Harold Gabriel.
- Added support for bluetooth interface "bnep0" present on some rooted phone. Thanks to Jérémy Derussé.
- Improved performance. Compute the counter value only if needed. Thanks to Jérémy Derussé.
- Added Polish translation. Many thanks to Jan Płoszczyca.
- Added Chinese Traditional translation. Many thanks to Bernie Garden.
- Added Spanish translation. Many thanks to Antonio David Fernández.
- Order data by date and then by interface name in CSV file.
- Fixed a few minor bugs.
- Added Czech translation. Many thanks to Petr Bláha.
- Added Italian translation. Many thanks to Fabio Bonomi Boseggia.
- Added weekly counter.
- Rewrote dialogs handling. Dialogs are now restored on configuration changes.
- Added export to the SD card. Format is CSV.
- Fixed French translation. Escaped "'".
- Fixed a possible "Force closed" on counter type changes.
- Added French translation.
- Replaced "For X days" with "X days ago".
- Rewritten lots of code. Easier to extend now.
- German translation. Many thanks to Thomas Putschbach.
- Added alerts on a counter basis if the defined limit is exceeded. Initial implementation. Needs some work.
- Added more counters customizable using the "duration" option. Previous counters must be redefined. Sorry... But the byte count will be kept.
- First open-source release.
- Some bug fixes and minor changes.
- Added refresh button in the main menu.
- Added donate button in the about dialog.
- Some bug fixes.
- Hopefully fixed some "force closed".
- Added animation on resume.
- Added confirmation dialog for "reset all".
- Added percentage to the detail dialog.
- A few minor UI changes.
- Simplified UI layout. Only total values are shown. Click on the counter to get more information.
- Added monthly counter. Defaults to the 1th of the month. Long click the counter to set another date.
- Added detail dialog. Click on the counter to see details.
- Improved background service. The statistics should be more reliable now.
- Save statistics on a daily basis for more flexibility. Previous data will be erased during the upgrade. Sorry.
- Added dynamic counters. Counters can now be added, removed and modified. Currently "Total", "Last 30 days", "Last 7 days" and "Today" are available.
- Removed session counter.
- Improved UI layout. Added some icons, changed layout, improved dialog.
- Initial release.
This is a list of planned features for the future releases.
"Monthly" counter with user-defined date.
- Alert/notification if counter exceeds a given limit. (partially done)
Refactor, clean-up the code and synchronize the threads correctly. Make NetCounter open-source. Export data and also (probably) import. Add preferences (notifications, update rate, etc).
- Reorder counters.
If you do not have access to the Android Market, you can still download and install NetCounter from here.
- netcounter-0.14 sha1sum: a10e8e9c62ed1d14699be05deb274d504c056938
- netcounter-0.14 sha1sum: 865215c65310d0906c3fb36519b6c53a80c9e554
- netcounter-0.13.1 sha1sum: 01131494152555c1b313c05824b660610eb81720
- netcounter-0.13 sha1sum: c4b920042d8008563b5c511058d8a4a7cada14af
- netcounter-0.12.2 sha1sum: f976e21abc8537a6521f4dcf8c37fe765239f962
- netcounter-0.12.1 sha1sum: becdfdc8574f0ba60c3879cc51a819695929e951
- netcounter-0.12 sha1sum: fe002f59973feb57ec0ecc949d4fff53154f1247
- netcounter-0.11.1 sha1sum: eb269e03e782ea1cd97528222f3b3ccdab5d9fc4
- netcounter-0.10 sha1sum: cc5aec5fa886dc7d1f6874a3abd5c1a137f31247
Getting the source
NetCounter is an open-source software available under the GPLv3 license. You can get the code from my Subversion repository. Feel free to look at it and submit patches if you find bugs or want to improve something.
To get the latest version, use:
svn co https://www.jaqpot.net/svn/android/netcounter/trunk netcounter
I strongly recommend that you check out the project using Eclipse as it is already configured for it.
I see/saw negative values. What should I do?
You should first upgrade to 0.12. The bug should be fixed in this release. It happened when the underlying statistics overflowed and started again at 0. This is the case if you download/upload a lot (at around 2GB I think). However, if you encounter this bug in the past, your database probably contains wrong values. To check/fix it, use the export function and verify that there are no negative values in the file. If you find one or more, edit the file (make a copy first) and replace the negative values with correct ones (you will have to find, guess or imagine them. Sorry...). Save the file. Reset all the data of the affected interface(s) and use the import function to import the values again. That's it.
What are those netcounter-xxxxxx.csv files on my SD card?
When you click on "Export to .csv" (in the advanced preferences), NetCounter dumps the whole database into a file. The comma-separated values file is written at the root of the sdcard and can be opened with a text editor or any spreadsheet software like OpenOffice.org Calc and generate graphs. The interface names "rmnet0" and "tiwlan0" correspond respectively to EDGE/3G and Wi-Fi. Those names can be different on your mobile phone. The "rx" and "tx" values are bytes. The filename contains the Unix time of the export.
Can I also import those netcounter-xxxxx.csv files?
Yes, since 0.11. NetCounter will automatically import the exported files created with the export function. NetCounter does not overwrite values already present in the database. So the recommended procedure is:
- Do a last export (if needed).
- Reset all the data of the interface you want to import. Long-click on the interface item in the main screen to do this.
- Import the data.
NetCounter runs in the background. Will it drain my battery faster?
No and yes. Let me explain why. Yes because every time an application runs, it needs some power. No because NetCounter uses the AlarmManager in order to be woken up when needed. The rest of the time, NetCounter does nothing in the background. When woken up, NetCounter acquires a WAKE_LOCK for the small amount of time (a hundred milliseconds) needed to update its database. This operation is performed once every hour while on 3G/EDGE and every 30 seconds while on WiFi. So NetCounter should have an insignificant impact on battery life.
Notifications/alerts only appear/disappear after a long time. What's happening?
First of all, notifications/alerts are in a beta stage and thus may be buggy. As explain above, NetCounter only wake up once an hour when in background in order to save power. Notifications/alerts get evaluated at this time so currently it is possible that notifications "lag" a bit.
What is the WiFi slow update rate option?
When WiFi is on, NetCounter updates its database every 30 seconds. When WiFi is turned off, Android unloads the driver and all the statistics are gone. The only reliable way to not lose these data is to poll regularly for them. But this also means more power consumption. If WiFi statistics are not relevant to you, you can enable the WiFi slow update rate option.
NetCounter needs the WAKE_LOCK permission. Will it drain my battery faster?
Please see above.
How accurate is NetCounter?
As much as it can without impacting user experience too much. There are many problem here. First, Android does not provide any API to get network statistics. So all the data are gathered from the underlying Linux system. Driver loading/unloading reset the statistics and powering off the phone too. Neither of these events are communicated to Android applications. The only way to get reliable statistics is to poll for them. If you poll frequently, the data will be more accurate but your battery will be emptied pretty fast. So it is a trade-off between accuracy and power consumption. Second, your provider may count data in a different manner than NetCounter does (e.g. accounting at least 400kB for every session).
Can I improve the accuracy of NetCounter?
I suggest you quickly start NetCounter just before powering for phone off or just before you switch WiFi off. So you will see your data consumption and NetCounter will record the latest statistics.
Does NetCounter access the Internet in the background?
No. NetCounter does not perform any network operations.
|Main screen.||Long click on an interface item to add a new counter or reset the data.|
|Long click on a counter item to change its type or remove it.||Click on a counter item to see more details.|
|Select the type of a counter.||Set the start date of your data plan for the monthly counter.|
If you have some suggestions, bug reports or questions, you can contact me at firstname.lastname@example.org. Please, remember that I will not add too many additional features in order to keep NetCounter simple.
If you like this application, you can donate money using PayPal. I would really appreciate it.
Copyright 2009-2010 Cyril Jaquier