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 8881959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:27:28+00:00 2026-06-14T20:27:28+00:00

The minimum SDK version for my project is 7, I am not able to

  • 0

The minimum SDK version for my project is 7, I am not able to use TrafficStats out of the box. Therefore, currently I am using an approach based on reflection as shown here. The main problem with that is that I cannot have this stats on devices with earlier than Android 2.3, it just gives me the possibility to do not Force Close on a 2.1 device.

Then now I am looking for a way to use the TrafficStatsCompat as it is described on the doc as “Helper for accessing features in TrafficStats introduced after API level 14 in a backwards compatible fashion.”

My main problem is that I could not find any example on how to use this compatibility class. I’ve been looking for other classes inside the support library so I could try to mimic the behavior on how to use it, but I was not successful. Can someone provide an example on how to use the TrafficStats methods, e.g., getTotalTxBytes, but with TrafficStatsCompat.

  • 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-14T20:27:29+00:00Added an answer on June 14, 2026 at 8:27 pm

    Can someone provide an example on how to use the TrafficStats methods, e.g., getTotalTxBytes, but with TrafficStatsCompat.

    No, because that class has nothing to do with accessing traffic stats on API Level 7. It does precisely what you quoted: it helps developers use methods added to TrafficStats after API Level 14.

    There is no way for you to get traffic information prior to API Level 8 when TrafficStats was introduced.


    UPDATE

    Since trying to answer the comment in a comment was going to be painful…

    You only need to play reflection games like that if you are continuing to support Android 1.x (and if you are, you are a saint).

    If you are sticking to Android 2.x and higher, you can simply route using Build:

    if (Build.VERSION.SDK_INT>=Build.VERSION_CODES.FROYO) {
        // do something involving TrafficStats
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there any minimum compute capability to use CUDA-OpenGL interoperability? I did not find
I have made an app for android and have kept the minimum sdk version
Is there any minimum iOS version restrictions on using full-sized retina 4 screen? May
I have created a Widget in with minimum sdk version 14 for a ICS
I created an application that will release to the market. The minimum SDK version
I have problem with adding events to Android Calendar. My minimum SDK version is
Platform: MonoDroid v4.2.4 IDE: Visual Studio 2012 Minimum SDK version: API 12 I'm having
How can I apply zoom control in an ImageView dynamically? My minimum SDK version
The minimum sdk of my app is 7, but I can use DialogFragment which
What is the minimum SDK version for the Android Support Library

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.