目录搜索
androidManifestManifest.permissionManifest.permission_groupandroid.accessibilityserviceAccessibilityServiceandroid.accountsAccountandroid.appNotificationManagerandroid.bluetoothBluetoothAdapterBluetoothClassBluetoothClass.DeviceBluetoothClass.Device.MajorBluetoothClass.ServiceBluetoothDeviceBluetoothServerSocketBluetoothSocketandroid.contentSharedPreferencesandroid.database.sqliteSQLiteCursorDriverSQLiteOpenHelperandroid.graphicsBitmapandroid.locationLocationListenerGeocoderGpsStatusGpsStatus.ListenerGpsStatus.NmeaListenerGpsSatelliteandroid.mediaAudioFormatAsyncPlayerAudioRecordAudioRecord.OnRecordPositionUpdateListenerThumbnailUtilsAudioManagerandroid.netTrafficStatsMailToLocalSocketandroid.osAsyncTaskAsyncTask.StatusCountDownTimerMessageMessageQueueHandlerThreadandroid.textHtmlandroid.utilJsonWriterandroid.viewContextMenuContextMenu.ContextMenuInfoDisplayViewManagerViewViewStubViewTreeObserverViewParentWindowManagerGestureDetectorGravityMenuInflaterScaleGestureDetectorSoundEffectConstantsandroid.view.inputmethodInputConnectionInputMethodInputMethodSessionBaseInputConnectionInputMethodManagerandroid.widgetAbsListViewAbsListView.LayoutParamsAbsListView.OnScrollListenerAbsListView.RecyclerListenerAbsoluteLayoutAbsoluteLayout.LayoutParamsAbsSeekBarAbsSpinnerAdapterViewAdapterView.AdapterContextMenuInfoAdapterView.OnItemLongClickListenerAdapterView.OnItemSelectedListenerAdapterView.OnItemClickListenerAnalogClockBaseAdapterBaseExpandableListAdapterButtonCheckBoxCheckedTextViewCheckableChronometerChronometer.OnChronometerTickListenerCompoundButtonCompoundButton.OnCheckedChangeListenerCursorAdapterCursorTreeAdapterDatePickerDatePicker.OnDateChangedListenerDialerFilterDigitalClockEditTextFilterFilter.FilterListenerFilter.FilterResultsExpandableListAdapterExpandableListView.OnChildClickListenerExpandableListView.OnGroupClickListenerExpandableListView.OnGroupCollapseListenerExpandableListView.OnGroupExpandListenerFilterableGalleryGallery.LayoutParamsGridViewGridLayoutGridLayout.AlignmentRadioGroupImageViewImageView.ScaleTypeHorizontalScrollViewImageButtonImageSwitcherFilterQueryProviderListAdapterListViewMediaControllerMultiAutoCompleteTextViewMultiAutoCompleteTextView.CommaTokenizerMultiAutoCompleteTextView.TokenizerQuickContactBadgeRadioButtonRatingBarRatingBar.OnRatingBarChangeListenerRelativeLayoutRemoteViewsResourceCursorAdapterResourceCursorTreeAdapterScrollerScrollViewSearchViewSearchView.OnCloseListenerSearchView.OnQueryTextListenerSearchView.OnSuggestionListenerSeekBarSeekBar.OnSeekBarChangeListenerSimpleAdapterSimpleAdapter.ViewBinderSimpleCursorAdapterSimpleCursorAdapter.CursorToStringConverterSimpleCursorAdapter.ViewBinderSimpleCursorTreeAdapterSimpleCursorTreeAdapter.ViewBinderSimpleExpandableListAdapterSlidingDrawerSlidingDrawer.OnDrawerCloseListenerSlidingDrawer.OnDrawerOpenListenerSlidingDrawer.OnDrawerScrollListenerSpinnerSpinnerAdapterWrapperListAdapterTabHostTabHost.TabSpecTextViewTimePickerTimePicker.OnTimeChangedListenerToastTableLayoutTableLayout.LayoutParamsTableRowTableRow.LayoutParamsTabWidgetTextSwitcherToggleButtonTwoLineListItemVideoViewViewAnimatorViewFlipperViewSwitcherViewSwitcher.ViewFactoryZoomButtonsControllerZoomButtonsController.OnZoomListenerZoomButtonZoomControlsdalvik.systemDexFile
文字


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类的使用


上一篇:下一篇: