Now a days Internet access is very costly.The provider used charges like hell. We do not use unlimited plan for internet.That's why I would like to develop an that can facilities to calculate(manage) network package/data usage.
Suppose I have activated 5GB data plan.So I need to check before surfing net,upload/download things.
I know some Data provider provides these facility .I want to capture network data packets on my android device by my app. But How can I do that into my own code. Any help will be appreciated. Thank you advance
Please check that.
TextView infoView = (TextView)findViewById(R.id.traffic_info);
String info = "";
info += "Mobile Interface:\n";
info += ("\tReceived: " + TrafficStats.getMobileRxBytes() + " bytes / " + TrafficStats.getMobileRxPackets() + " packets\n");
info += ("\tTransmitted: " + TrafficStats.getMobileTxBytes() + " bytes / " + TrafficStats.getMobileTxPackets() + " packets\n");
info += "All Network Interface:\n";
info += ("\tReceived: " + TrafficStats.getTotalRxBytes() + " bytes / " + TrafficStats.getTotalRxPackets() + " packets\n");
info += ("\tTransmitted: " + TrafficStats.getTotalTxBytes() + " bytes / " + TrafficStats.getTotalTxPackets() + " packets\n");
infoView.setText(info);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With