使用Service监听上下行流量数据
老样子,直接上东西
public class FlowService extends Service { private long mCurrentUP=0;//当前手机的上行流量 private long mCurrentDOWN=0;//当前手机的下行流量 private long mLastUP=0;//上次手机的上行流量 private long mLastDOWN=0;//上次手机的下行流量 // 进行换算过后的上传下载速率 private String lUP = ""; private String lDOWN = ""; @Override public IBinder onBind(Intent intent) { // TODO Auto-generated method stub return null; } @Override public void onCreate() { // TODO Auto-generated method stub super.onCreate(); } @Override public int onStartCommand(Intent intent, int flags, int startId) { // TODO Auto-generated method stub //初始化获得流量总量 mLastUP = TrafficStats.getTotalTxBytes(); mLastDOWN = TrafficStats.getTotalRxBytes(); handler.sendEmptyMessage(128); return super.onStartCommand(intent, flags, start