Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8668253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:10:03+00:00 2026-06-12T18:10:03+00:00

For statistic network traffic per APP, what I’m using now is Android TrafficStats That

  • 0

For statistic network traffic per APP, what I’m using now is Android TrafficStats

That I can get result like following :

  • Youtube 50.30 MBytes
  • Facebook 21.39 MBytes
  • Google Play 103.38 MBytes
  • (and more…)

As I know, the “Android Trafficstats” just a native pointer to a c file. (maybe an .so ?)

But it mixed Wifi & 3g traffic, is there any way to only get non-WiFi traffic statistic ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T18:10:04+00:00Added an answer on June 12, 2026 at 6:10 pm

    Evening all, I got some way to do that…

    First I have to create a class which extends BroadcasrReceiver, like this:

    Manifest definition:

    <receiver android:name=".core.CoreReceiver" android:enabled="true" android:exported="false">
      <intent-filter>
        <action android:name="android.net.ConnectivityManager.CONNECTIVITY_ACTION" />
        <action android:name="android.net.wifi.STATE_CHANGE" />
      </intent-filter>
    </receiver>
    

    Codes:

    /**
     * @author me
     */
    public class CoreReceiver extends BroadcastReceiver {
      public void onReceive(Context context, Intent intent) {
        if (Constants.phone == null) {
          // Receive [network] event
          Constants.phone=new PhoneListen(context);
          TelephonyManager telephony=(TelephonyManager) 
          context.getSystemService(Context.TELEPHONY_SERVICE);
          telephony.listen(Constants.phone, PhoneStateListener.LISTEN_DATA_CONNECTION_STATE);
        }
    
        WifiManager wifi=(WifiManager)context.getSystemService(Context.WIFI_SERVICE);
        boolean b=wifi.isWifiEnabled();
        if (Constants.STATUS_WIFI != b) {
           // WiFi status changed...
        }
      }
    }
    

    And a phone stats listener below…

    public class PhoneListen extends PhoneStateListener {
      private Context context;    
      public PhoneListen(Context c) {
         context=c;
      }    
      @Override
      public void onDataConnectionStateChanged(int state) {
        switch(state) {
          case TelephonyManager.DATA_DISCONNECTED:// 3G
            //3G has been turned OFF
          break;
          case TelephonyManager.DATA_CONNECTING:// 3G
            //3G is connecting
          break;
          case TelephonyManager.DATA_CONNECTED:// 3G
            //3G has turned ON
          break;
        }
      }
    }
    

    Finally, here’s my logic

    1. Collect count into SQLite DB.
    2. Collect all app network usage via TrafficStats every 1 minute, only when 3G is ON.
    3. If 3G is OFF, then stop collecting.
    4. If both 3G & WiFi are ON, stop collecting.

    As I know, network traffic will go through WiFi only, if both 3G & WiFi are available.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to get Network Statistics for my Windows 7 system using PyWin32
I am working on an app that monitors network usage. However I noticed many
How can I obtain the (IPv4) addresses for all network interfaces using only proc
I see on sites that they sometimes have a statistic showing how many views
I'm generating a power model using Multilayer Perceptron on Weka which is a statistic
#include<iostream> using namespace std; /*main idea is to construct ordered statistic tree,which is similar
I would like to write a piece of code which checks, for each network
Is there anyone using git in such a fashion? I would like to distribute
I'm interesting with statistic and motivation of using task list in VS. Why are
I would like to see some statistic and visual states of my git repository.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.