4

Does someone know a way to get only the GPRS data usage (excluding Wifi data) programmatically?

RadioInfo.getNumberOfPacketsReceived() 

and

RadioInfo.getNumberOfPacketsSent()

methods return the total data received and sent. But I want to get GPRS data received and sent(optionally Wifi data count).

A sample application called miniMoni seems to do this. But I could find any code sample for this task. Please give me some guidance on this?

Please note that I want to get the total GPRS usage of the device, not the usage of a single application.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
user1177489
  • 157
  • 2
  • 7
  • I personally know of no way to do exactly this. [According to this similar question](http://stackoverflow.com/a/811476/119114), these guys don't either. – Nate Mar 05 '13 at 08:13

1 Answers1

1

Disclaimer: I'm not a RIM expert, but...there is a clue of a possible way to do this on the page that is linked above, where it talks about the TransportDescripter.

If you can get the TransportDescripter (available from API v5.0.0), you can possibly know whether data is currently being routed via GPRS or WiFi (note this is NOT the same as having either connection open).

If you know this, you can use RadioInfo.GetNumberOfPacketsSent and RadioInfo.GetNumberOfPacketsReceived to calculate the packets that are sent and received while you have a GPRS connection.

Connect
Get TransportDescriptor = GPRS
Get PacketsSent/Received
Get PacketsSent/Received
Connection switches to WiFi
Get PacketsSent/Received immediately (I)
GPRS Packets = Packets (I)
Connection switches to GPRS
Get PacketsSent/Received immediately (II)
WiFi Packets = Packets (II) minus Packets (I)
and so on.

It gives only an estimate, and involves some slightly messy code. As I say, this is only a guess from reading the documentation...I'd be interested if anyone points out why this method wouldn't work though.

user1725145
  • 3,993
  • 2
  • 37
  • 58