annuaire recherche
android Manifest Manifest.permission Manifest.permission_group android.accessibilityservice AccessibilityService android.accounts Account android.app NotificationManager android.bluetooth BluetoothAdapter BluetoothClass BluetoothClass.Device BluetoothClass.Device.Major BluetoothClass.Service BluetoothDevice BluetoothServerSocket BluetoothSocket android.content SharedPreferences android.database.sqlite SQLiteCursorDriver SQLiteOpenHelper android.graphics Bitmap android.location LocationListener Geocoder GpsStatus GpsStatus.Listener GpsStatus.NmeaListener GpsSatellite android.media AudioFormat AsyncPlayer AudioRecord AudioRecord.OnRecordPositionUpdateListener ThumbnailUtils AudioManager android.net TrafficStats MailTo LocalSocket android.os AsyncTask AsyncTask.Status CountDownTimer Message MessageQueue HandlerThread android.text Html android.util JsonWriter android.view ContextMenu ContextMenu.ContextMenuInfo Display ViewManager View ViewStub ViewTreeObserver ViewParent WindowManager GestureDetector Gravity MenuInflater ScaleGestureDetector SoundEffectConstants android.view.inputmethod InputConnection InputMethod InputMethodSession BaseInputConnection InputMethodManager android.widget AbsListView AbsListView.LayoutParams AbsListView.OnScrollListener AbsListView.RecyclerListener AbsoluteLayout AbsoluteLayout.LayoutParams AbsSeekBar AbsSpinner AdapterView AdapterView.AdapterContextMenuInfo AdapterView.OnItemLongClickListener AdapterView.OnItemSelectedListener AdapterView.OnItemClickListener AnalogClock BaseAdapter BaseExpandableListAdapter Button CheckBox CheckedTextView Checkable Chronometer Chronometer.OnChronometerTickListener CompoundButton CompoundButton.OnCheckedChangeListener CursorAdapter CursorTreeAdapter DatePicker DatePicker.OnDateChangedListener DialerFilter DigitalClock EditText Filter Filter.FilterListener Filter.FilterResults ExpandableListAdapter ExpandableListView.OnChildClickListener ExpandableListView.OnGroupClickListener ExpandableListView.OnGroupCollapseListener ExpandableListView.OnGroupExpandListener Filterable Gallery Gallery.LayoutParams GridView GridLayout GridLayout.Alignment RadioGroup ImageView ImageView.ScaleType HorizontalScrollView ImageButton ImageSwitcher FilterQueryProvider ListAdapter ListView MediaController MultiAutoCompleteTextView MultiAutoCompleteTextView.CommaTokenizer MultiAutoCompleteTextView.Tokenizer QuickContactBadge RadioButton RatingBar RatingBar.OnRatingBarChangeListener RelativeLayout RemoteViews ResourceCursorAdapter ResourceCursorTreeAdapter Scroller ScrollView SearchView SearchView.OnCloseListener SearchView.OnQueryTextListener SearchView.OnSuggestionListener SeekBar SeekBar.OnSeekBarChangeListener SimpleAdapter SimpleAdapter.ViewBinder SimpleCursorAdapter SimpleCursorAdapter.CursorToStringConverter SimpleCursorAdapter.ViewBinder SimpleCursorTreeAdapter SimpleCursorTreeAdapter.ViewBinder SimpleExpandableListAdapter SlidingDrawer SlidingDrawer.OnDrawerCloseListener SlidingDrawer.OnDrawerOpenListener SlidingDrawer.OnDrawerScrollListener Spinner SpinnerAdapter WrapperListAdapter TabHost TabHost.TabSpec TextView TimePicker TimePicker.OnTimeChangedListener Toast TableLayout TableLayout.LayoutParams TableRow TableRow.LayoutParams TabWidget TextSwitcher ToggleButton TwoLineListItem VideoView ViewAnimator ViewFlipper ViewSwitcher ViewSwitcher.ViewFactory ZoomButtonsController ZoomButtonsController.OnZoomListener ZoomButton ZoomControls dalvik.system DexFile
personnages


TrafficStats

版本:Android 2.3 r1

结构

继承关系

public class TrafficStats extends Object

java.lang.Object

android.net.TrafficStats

类概述

提供网络流量统计的类。这些统计包括通过所有网络接口、mobile接口和UID网络接口的字节发送和接收,网络数据包的发送和接收。

这些统计可能不适用于所有平台。如果本设备不支持统计,UNSUPPORTED将被返回。

常量

public static final int UNSUPPORTED

返回值表示该设备不支持统计。

常量值: -1 (0xffffffff)

公共方法

public static long getMobileRxBytes ()

获取通过Mobile接口接收到的字节总数(Android123:这里不包含WiFi

返回值

字节总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getMobileRxPackets ()

获取通过Mobile接口接收到的数据包总数

返回值

数据包总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getMobileTxBytes ()

获取通过Mobile接口发送的字节总数

返回值

字节总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getMobileTxPackets ()

获取通过Mobile接口发送的数据包总数

返回值

数据包总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getTotalRxBytes ()

获取通过所有网络接口接收到的字节总数。(Android123:包含MobileWiFi等)

返回值

字节总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getTotalRxPackets ()

获取通过所有网络接口接收到的数据包总数。(Android123:包含MobileWiFi等)

返回值

数据包总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getTotalTxBytes ()

获取通过所有网络接口发送的字节总数。(Android123:包含MobileWiFi等)

返回值

字节总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getTotalTxPackets ()

获取通过所有网络接口发送的数据包总数(Android123:包含MobileWiFi等)

返回值

数据包总数。如果本设备不支持统计,将返回UNSUPPORTED

public static long getUidRxBytes (int uid)

获取通过UID网络接口收到的字节数。统计包含所有网络接口。

参数

uid 待检查的进程的uid

返回值

字节数

参见

myUid()

public static long getUidTxBytes (int uid)

获取通过UID网络接口发送的字节数。统计包含所有网络接口。

参数

uid 待检查的进程的uid

返回值

字节总数。如果本设备不支持统计,将返回UNSUPPORTED

参见

myUid()

补充

文章链接

Android流量统计TrafficStats类的使用


Article précédent: Article suivant: