1

We have an Android app with over a million active users. We recently started receiving feedbacks from users complaining that our app consumes huge amount of network data when in background (around 0.5-3 gigabytes in a week).

The app doesn't have any operations in the background except for the push notifications receiver which doesn't have any network calls. the data consumption on the background should be less than 10 megabytes for a week for sure.

Is there a code I can use to help me detect the cause for this data consumption when my app is in background?

Is there a way to limit data access from all SDKs when my app is in background?

In general, what's the best way to approach such a problem?

Thanks

Update:

In our case we found eventually that the source of the problem was from an SDK we integrated with the app.

If you have the same issue, I suggest you look closely at all your 3rd party code in the app, especially new libraries you added.

Second, check all the services that your app define in the manifest, look closely if any of those services can be the source for this problem.

Third, look for places in the app that use network operation with a re-try mechanism, there could be an infinite "while loop" trying to send some data to a server (maybe some sort of reporting or analytics).

Oded Regev
  • 4,065
  • 2
  • 38
  • 50
  • You mean connection data? – MineConsulting SRL Nov 05 '14 at 14:12
  • Yes, network consumption – Oded Regev Nov 05 '14 at 14:16
  • You need to provide more information. What your app is supposed to do in background? How it connects to the internet? Have you calculated how much data your app is supposed to use and how this value differs from the 0.5-3gg one? – Salem Nov 05 '14 at 14:27
  • The app doesn't have any operations in the background except for the push notifications receiver which doesn't have any network calls. the data consumption on the background should be less than 10 megabytes for a week for sure. My guess is that some SDK is causing this, but I don't know how to detect which one – Oded Regev Nov 05 '14 at 14:48
  • check through app manager that if any service or process is running? – Chitrang Nov 05 '14 at 18:01
  • My guess is you broke your push notifications and what do you mean your guess is some SDK? – danny117 Nov 10 '14 at 02:55
  • @OdedRegev what is that SDK caused this issue can you name it please, even we are facing the huge data consumption around 2GB/Day – Suresh Maidaragi Jan 28 '23 at 13:06
  • @danny117 can you elaborate what broke in push notification – Suresh Maidaragi Jan 28 '23 at 15:34
  • back in 2014 I was thinking I don't remember. But Someone has to pay for bandwidth. Anyways good to see ya I'm trying to get back in android again trying an all kotlin app. – danny117 Jan 28 '23 at 17:13

2 Answers2

1

You need to inspect the traffic coming over the wire from your devices. You will need one computer and your device connected to the same local network.

  1. Set up a debugging proxy like Fiddler on a machine on your local network and note its IP address. This assumes your app communicates via HTTP.
  2. Connect your test device(s) via WiFi to the same network as your debugging machine.
  3. Configure your Android devices to use a proxy that points to your debugging machine.

Now you will be able to inspect all requests originating from the device(s). Presumably you will have to leave them running for some time to replicate the problem of some kind of periodic background service running and downloading data. However, I can tell you now that push notifications themselves are not causing 3GB of data on a single device.

Community
  • 1
  • 1
Jeffrey Mixon
  • 12,846
  • 4
  • 32
  • 55
0

You can write code for count the data usage as follows.

  recived = TrafficStats.getUidRxBytes(uid);// uid is your appID
send = TrafficStats.getUidTxBytes(uid);

TrafficStats.getMobileRxBytes(); 
TrafficStats.getMobileTxBytes(); 

TrafficStats.getTotalRxBytes();
TrafficStats.getTotalTxBytes();

and there is good answer you can find here..

App data usage finding

Community
  • 1
  • 1
Santhi Bharath
  • 2,818
  • 3
  • 28
  • 42
  • 1
    I need to know specifically which SDK in my app is causing this problem. TrafficStats can only bring stats for the entire app – Oded Regev Nov 05 '14 at 15:11