Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Visitor
Posts: 1
Registered: ‎10-27-2011
My Device: Bold
My Carrier: Rogers

API for Phone Statistics

 

Hi - I would like to be able to detect when the telephone carrier is changing due to roaming. As well, I would like to be able to read the country code of the carrier and the carrier unique id.

 

Is it also possible to read the amount of text messages transmitted in terms of data size?

 

Finally, can I get calling statistics such as the amount of voice calling used on the phone within a specific period?

 

Thanks!

Highlighted
Contributor
Posts: 10
Registered: ‎10-13-2011
My Device: 9900
My Carrier: T-mobile

Re: API for Phone Statistics

Hi,

 

try begin with class:

net.rim.device.api.system.RadioInfo
Developer
Posts: 204
Registered: ‎08-09-2010
My Device: 9930, PlayBook
My Carrier: Verizon Wireless

Re: API for Phone Statistics

Here are a couple of classes that I use along with the implementation:

 

//country data includes MccCode, Abbreviation, and Name

CountryData current = CountryCode.retrieve();

 



------------------------CountryCode.java---------------------------------


import java.util.Hashtable;

import net.rim.device.api.system.CDMAInfo;
import net.rim.device.api.system.RadioInfo;
import net.rim.device.api.system.SIMCardInfo;
import net.rim.device.api.util.IntHashtable;

 

public class CountryCode
{
public static IntHashtable Lookup;

static
{
Lookup = new IntHashtable();
for (int i = 0; i < CountryData.completeList.size(); i++)
{
CountryData data = (CountryData) CountryData.completeList.elementAt(i);
Lookup.put(data.MccCode, data);
}
}

public static CountryData retrieve()
{
CountryData data = null;;
try
{
int index = RadioInfo.getCurrentNetworkIndex();
if(index>-1)
{
int id = RadioInfo.getMCC(index);
if(id>-1)
{
data = (CountryData) Lookup.get(id);
}
}

}
catch (Exception e)
{
// TODO: handle exception
}
if(data==null)
{

//default to USA
data = (CountryData) Lookup.get(0x310);
}
return data;
}

}

--------------------------------------------------------------------------------- 

 

 


------------------------CountryData.java---------------------------------- 

import java.util.Vector;

public class CountryData
{

public static Vector completeList=new Vector();

public int MccCode=0;
public String Abbreviation="";
public String Name="";

public CountryData(int mccCode,String abbreviation,String name)
{
this.MccCode = mccCode;
this.Abbreviation = abbreviation;
this.Name = name;
}

static
{
completeList.addElement(new CountryData(0x412,"AF","Afghanistan"));
completeList.addElement(new CountryData(0x276,"AL","Albania"));
completeList.addElement(new CountryData(0x603,"DZ","Algeria"));
completeList.addElement(new CountryData(0x544,"AS","American Samoa (US)"));
completeList.addElement(new CountryData(0x213,"AD","Andorra"));
completeList.addElement(new CountryData(0x631,"AO","Angola"));
completeList.addElement(new CountryData(0x365,"AI","Anguilla"));
completeList.addElement(new CountryData(0x344,"AG","Antigua and Barbuda"));
completeList.addElement(new CountryData(0x722,"AR","Argentine Republic"));
completeList.addElement(new CountryData(0x283,"AM","Armenia"));
completeList.addElement(new CountryData(0x363,"AW","Aruba (Netherlands)"));
completeList.addElement(new CountryData(0x505,"AU","Australia"));
completeList.addElement(new CountryData(0x232,"AT","Austria"));
completeList.addElement(new CountryData(0x400,"AZ","Azerbaijani Republic"));
completeList.addElement(new CountryData(0x364,"BS","Bahamas"));
completeList.addElement(new CountryData(0x426,"BH","Bahrain"));
completeList.addElement(new CountryData(0x470,"BD","Bangladesh"));
completeList.addElement(new CountryData(0x342,"BB","Barbados"));
completeList.addElement(new CountryData(0x257,"BY","Belarus"));
completeList.addElement(new CountryData(0x206,"BE","Belgium"));
completeList.addElement(new CountryData(0x702,"BZ","Belize"));
completeList.addElement(new CountryData(0x616,"BJ","Benin"));
completeList.addElement(new CountryData(0x350,"BM","Bermuda (UK)"));
completeList.addElement(new CountryData(0x402,"BT","Bhutan"));
completeList.addElement(new CountryData(0x736,"BO","Bolivia"));
completeList.addElement(new CountryData(0x218,"BA","Bosnia and Herzegovina"));
completeList.addElement(new CountryData(0x652,"BW","Botswana"));
completeList.addElement(new CountryData(0x724,"BR","Brazil"));
completeList.addElement(new CountryData(0x348,"VG","British Virgin Islands (UK)"));
completeList.addElement(new CountryData(0x528,"BN","Brunei Darussalam"));
completeList.addElement(new CountryData(0x284,"BG","Bulgaria"));
completeList.addElement(new CountryData(0x613,"BF","Burkina Faso"));
completeList.addElement(new CountryData(0x642,"BI","Burundi"));
completeList.addElement(new CountryData(0x456,"KH","Cambodia"));
completeList.addElement(new CountryData(0x624,"CM","Cameroon"));
completeList.addElement(new CountryData(0x302,"CA","Canada"));
completeList.addElement(new CountryData(0x625,"CV","Cape Verde"));
completeList.addElement(new CountryData(0x346,"KY","Cayman Islands (UK)"));
completeList.addElement(new CountryData(0x623,"CF","Central African Republic"));
completeList.addElement(new CountryData(0x622,"TD","Chad"));
completeList.addElement(new CountryData(0x730,"CL","Chile"));
completeList.addElement(new CountryData(0x460,"CN","China"));
completeList.addElement(new CountryData(0x461,"CN","China"));
completeList.addElement(new CountryData(0x732,"CO","Colombia"));
completeList.addElement(new CountryData(0x654,"KM","Comoros"));
completeList.addElement(new CountryData(0x629,"CG","Republic of the Congo"));
completeList.addElement(new CountryData(0x548,"CK","Cook Islands (NZ)"));
completeList.addElement(new CountryData(0x712,"CR","Costa Rica"));
completeList.addElement(new CountryData(0x612,"CI","Côte d'Ivoire"));
completeList.addElement(new CountryData(0x219,"HR","Croatia"));
completeList.addElement(new CountryData(0x368,"CU","Cuba"));
completeList.addElement(new CountryData(0x280,"CY","Cyprus"));
completeList.addElement(new CountryData(0x230,"CZ","Czech Republic"));
completeList.addElement(new CountryData(0x630,"CD","Democratic Republic of the Congo"));
completeList.addElement(new CountryData(0x238,"DK","Denmark"));
completeList.addElement(new CountryData(0x638,"DJ","Djibouti"));
completeList.addElement(new CountryData(0x366,"DM","Dominica"));
completeList.addElement(new CountryData(0x370,"DO","Dominican Republic"));
completeList.addElement(new CountryData(0x514,"TL","East Timor"));
completeList.addElement(new CountryData(0x740,"EC","Ecuador"));
completeList.addElement(new CountryData(0x602,"EG","Egypt"));
completeList.addElement(new CountryData(0x706,"SV","El Salvador"));
completeList.addElement(new CountryData(0x627,"GQ","Equatorial Guinea"));
completeList.addElement(new CountryData(0x657,"ER","Eritrea"));
completeList.addElement(new CountryData(0x372,"EE","Estonia"));
completeList.addElement(new CountryData(0x636,"ET","Ethiopia"));
completeList.addElement(new CountryData(0x750,"FK","Falkland Islands (Malvinas)"));
completeList.addElement(new CountryData(0x288,"FO","Faroe Islands (Denmark)"));
completeList.addElement(new CountryData(0x542,"FJ","Fiji"));
completeList.addElement(new CountryData(0x244,"FI","Finland"));
completeList.addElement(new CountryData(0x208,"FR","France"));
completeList.addElement(new CountryData(0x742,"GF","French Guiana (France)"));
completeList.addElement(new CountryData(0x547,"PF","French Polynesia (France)"));
completeList.addElement(new CountryData(0x628,"GA","Gabonese Republic"));
completeList.addElement(new CountryData(0x607,"GM","Gambia"));
completeList.addElement(new CountryData(0x282,"GE","Georgia"));
completeList.addElement(new CountryData(0x262,"DE","Germany"));
completeList.addElement(new CountryData(0x620,"GH","Ghana"));
completeList.addElement(new CountryData(0x266,"GI","Gibraltar (UK)"));
completeList.addElement(new CountryData(0x202,"GR","Greece"));
completeList.addElement(new CountryData(0x290,"GL","Greenland (Denmark)"));
completeList.addElement(new CountryData(0x352,"GD","Grenada"));
completeList.addElement(new CountryData(0x340,"GP","Guadeloupe (France)"));
completeList.addElement(new CountryData(0x535,"GU","Guam (US)"));
completeList.addElement(new CountryData(0x704,"GT","Guatemala"));
completeList.addElement(new CountryData(0x611,"GN","Guinea"));
completeList.addElement(new CountryData(0x632,"GW","Guinea-Bissau"));
completeList.addElement(new CountryData(0x738,"GY","Guyana"));
completeList.addElement(new CountryData(0x372,"HT","Haiti"));
completeList.addElement(new CountryData(0x708,"HN","Honduras"));
completeList.addElement(new CountryData(0x454,"HK","Hong Kong (PRC)"));
completeList.addElement(new CountryData(0x216,"HU","Hungary"));
completeList.addElement(new CountryData(0x274,"IS","Iceland"));
completeList.addElement(new CountryData(0x404,"IN","India"));
completeList.addElement(new CountryData(0x405,"IN","India"));
completeList.addElement(new CountryData(0x510,"ID","Indonesia"));
completeList.addElement(new CountryData(0x432,"IR","Iran"));
completeList.addElement(new CountryData(0x418,"IQ","Iraq"));
completeList.addElement(new CountryData(0x272,"IE","Ireland"));
completeList.addElement(new CountryData(0x425,"IL","Israel"));
completeList.addElement(new CountryData(0x222,"IT","Italy"));
completeList.addElement(new CountryData(0x338,"JM","Jamaica"));
completeList.addElement(new CountryData(0x441,"JP","Japan"));
completeList.addElement(new CountryData(0x440,"JP","Japan"));
completeList.addElement(new CountryData(0x416,"JO","Jordan"));
completeList.addElement(new CountryData(0x401,"KZ","Kazakhstan"));
completeList.addElement(new CountryData(0x639,"KE","Kenya"));
completeList.addElement(new CountryData(0x545,"KI","Kiribati"));
completeList.addElement(new CountryData(0x467,"KP","Korea, North"));
completeList.addElement(new CountryData(0x450,"KR","Korea, South"));
completeList.addElement(new CountryData(0x419,"KW","Kuwait"));
completeList.addElement(new CountryData(0x437,"KG","Kyrgyz Republic"));
completeList.addElement(new CountryData(0x457,"LA","Laos"));
completeList.addElement(new CountryData(0x247,"LV","Latvia"));
completeList.addElement(new CountryData(0x415,"LB","Lebanon"));
completeList.addElement(new CountryData(0x651,"LS","Lesotho"));
completeList.addElement(new CountryData(0x618,"LR","Liberia"));
completeList.addElement(new CountryData(0x606,"LY","Libya"));
completeList.addElement(new CountryData(0x295,"LI","Liechtenstein"));
completeList.addElement(new CountryData(0x246,"LT","Lithuania"));
completeList.addElement(new CountryData(0x270,"LU","Luxembourg"));
completeList.addElement(new CountryData(0x455,"MO","Macau (PRC)"));
completeList.addElement(new CountryData(0x294,"MK","Republic of Macedonia"));
completeList.addElement(new CountryData(0x646,"MG","Madagascar"));
completeList.addElement(new CountryData(0x650,"MW","Malawi"));
completeList.addElement(new CountryData(0x502,"MY","Malaysia"));
completeList.addElement(new CountryData(0x472,"MV","Maldives"));
completeList.addElement(new CountryData(0x610,"ML","Mali"));
completeList.addElement(new CountryData(0x278,"MT","Malta"));
completeList.addElement(new CountryData(0x551,"MH","Marshall Islands"));
completeList.addElement(new CountryData(0x340,"MQ","Martinique (France)"));
completeList.addElement(new CountryData(0x609,"MR","Mauritania"));
completeList.addElement(new CountryData(0x617,"MU","Mauritius"));
completeList.addElement(new CountryData(0x334,"MX","Mexico"));
completeList.addElement(new CountryData(0x550,"FM","Federated States of Micronesia"));
completeList.addElement(new CountryData(0x259,"MD","Moldova"));
completeList.addElement(new CountryData(0x212,"MC","Monaco"));
completeList.addElement(new CountryData(0x428,"MN","Mongolia"));
completeList.addElement(new CountryData(0x297,"ME","Montenegro (Republic of)"));
completeList.addElement(new CountryData(0x354,"MS","Montserrat (UK)"));
completeList.addElement(new CountryData(0x604,"MA","Morocco"));
completeList.addElement(new CountryData(0x643,"MZ","Mozambique"));
completeList.addElement(new CountryData(0x414,"MM","Myanmar"));
completeList.addElement(new CountryData(0x649,"NA","Namibia"));
completeList.addElement(new CountryData(0x536,"NR","Nauru"));
completeList.addElement(new CountryData(0x429,"NP","Nepal"));
completeList.addElement(new CountryData(0x204,"NL","Netherlands"));
completeList.addElement(new CountryData(0x362,"AN","Netherlands Antilles (Netherlands)"));
completeList.addElement(new CountryData(0x546,"NC","New Caledonia (France)"));
completeList.addElement(new CountryData(0x530,"NZ","New Zealand"));
completeList.addElement(new CountryData(0x710,"NI","Nicaragua"));
completeList.addElement(new CountryData(0x614,"NE","Niger"));
completeList.addElement(new CountryData(0x621,"NG","Nigeria"));
completeList.addElement(new CountryData(0x534,"MP","Northern Mariana Islands (US)"));
completeList.addElement(new CountryData(0x242,"NO","Norway"));
completeList.addElement(new CountryData(0x422,"OM","Oman"));
completeList.addElement(new CountryData(0x410,"PK","Pakistan"));
completeList.addElement(new CountryData(0x552,"PW","Palau"));
completeList.addElement(new CountryData(0x423,"PS","Palestine"));
completeList.addElement(new CountryData(0x714,"PA","Panama"));
completeList.addElement(new CountryData(0x537,"PG","Papua New Guinea"));
completeList.addElement(new CountryData(0x744,"PY","Paraguay"));
completeList.addElement(new CountryData(0x716,"PE","Perú"));
completeList.addElement(new CountryData(0x515,"PH","Philippines"));
completeList.addElement(new CountryData(0x260,"PL","Poland"));
completeList.addElement(new CountryData(0x268,"PT","Portugal"));
completeList.addElement(new CountryData(0x330,"PR","Puerto Rico (US)"));
completeList.addElement(new CountryData(0x427,"QA","Qatar"));
completeList.addElement(new CountryData(0x647,"RE","Réunion (France)"));
completeList.addElement(new CountryData(0x226,"RO","Romania"));
completeList.addElement(new CountryData(0x250,"RU","Russian Federation"));
completeList.addElement(new CountryData(0x635,"RW","Rwandese Republic"));
completeList.addElement(new CountryData(0x356,"KN","Saint Kitts and Nevis"));
completeList.addElement(new CountryData(0x358,"LC","Saint Lucia"));
completeList.addElement(new CountryData(0x308,"PM","Saint Pierre and Miquelon (France)"));
completeList.addElement(new CountryData(0x360,"VC","Saint Vincent and the Grenadines"));
completeList.addElement(new CountryData(0x549,"WS","Samoa"));
completeList.addElement(new CountryData(0x292,"SM","San Marino"));
completeList.addElement(new CountryData(0x626,"ST","São Tomé and Príncipe"));
completeList.addElement(new CountryData(0x420,"SA","Saudi Arabia"));
completeList.addElement(new CountryData(0x608,"SN","Senegal"));
completeList.addElement(new CountryData(0x220,"RS","Serbia (Republic of)"));
completeList.addElement(new CountryData(0x633,"SC","Seychelles"));
completeList.addElement(new CountryData(0x619,"SL","Sierra Leone"));
completeList.addElement(new CountryData(0x525,"SG","Singapore"));
completeList.addElement(new CountryData(0x231,"SK","Slovakia"));
completeList.addElement(new CountryData(0x293,"SI","Slovenia"));
completeList.addElement(new CountryData(0x540,"SB","Solomon Islands"));
completeList.addElement(new CountryData(0x637,"SO","Somalia"));
completeList.addElement(new CountryData(0x655,"ZA","South Africa"));
completeList.addElement(new CountryData(0x214,"ES","Spain"));
completeList.addElement(new CountryData(0x413,"LK","Sri Lanka"));
completeList.addElement(new CountryData(0x634,"SD","Sudan"));
completeList.addElement(new CountryData(0x746,"SR","Suriname"));
completeList.addElement(new CountryData(0x653,"SZ","Swaziland"));
completeList.addElement(new CountryData(0x240,"SE","Sweden"));
completeList.addElement(new CountryData(0x228,"CH","Switzerland"));
completeList.addElement(new CountryData(0x417,"SY","Syria"));
completeList.addElement(new CountryData(0x466,"TW","Taiwan"));
completeList.addElement(new CountryData(0x436,"TJ","Tajikistan"));
completeList.addElement(new CountryData(0x640,"TZ","Tanzania"));
completeList.addElement(new CountryData(0x520,"TH","Thailand"));
completeList.addElement(new CountryData(0x615,"TG","Togolese Republic"));
completeList.addElement(new CountryData(0x539,"TO","Tonga"));
completeList.addElement(new CountryData(0x374,"TT","Trinidad and Tobago"));
completeList.addElement(new CountryData(0x605,"TN","Tunisia"));
completeList.addElement(new CountryData(0x286,"TR","Turkey"));
completeList.addElement(new CountryData(0x438,"TM","Turkmenistan"));
completeList.addElement(new CountryData(0x376,"TC","Turks and Caicos Islands (UK)"));
completeList.addElement(new CountryData(0x641,"UG","Uganda"));
completeList.addElement(new CountryData(0x255,"UA","Ukraine"));
completeList.addElement(new CountryData(0x424,"AE","United Arab Emirates"));
completeList.addElement(new CountryData(0x430,"AE","United Arab Emirates (Abu Dhabi)"));
completeList.addElement(new CountryData(0x431,"AE","United Arab Emirates (Dubai)"));
completeList.addElement(new CountryData(0x235,"GB","United Kingdom"));
completeList.addElement(new CountryData(0x234,"GB","United Kingdom"));
completeList.addElement(new CountryData(0x310,"US","United States of America"));
completeList.addElement(new CountryData(0x311,"US","United States of America"));
completeList.addElement(new CountryData(0x312,"US","United States of America"));
completeList.addElement(new CountryData(0x313,"US","United States of America"));
completeList.addElement(new CountryData(0x314,"US","United States of America"));
completeList.addElement(new CountryData(0x315,"US","United States of America"));
completeList.addElement(new CountryData(0x316,"US","United States of America"));
completeList.addElement(new CountryData(0x332,"VI","United States Virgin Islands (US)"));
completeList.addElement(new CountryData(0x748,"UY","Uruguay"));
completeList.addElement(new CountryData(0x434,"UZ","Uzbekistan"));
completeList.addElement(new CountryData(0x541,"VU","Vanuatu"));
completeList.addElement(new CountryData(0x225,"VA","Vatican City State"));
completeList.addElement(new CountryData(0x734,"VE","Venezuela"));
completeList.addElement(new CountryData(0x452,"VN","Viet Nam"));
completeList.addElement(new CountryData(0x543,"WF","Wallis and Futuna (France)"));
completeList.addElement(new CountryData(0x421,"YE","Yemen"));
completeList.addElement(new CountryData(0x645,"ZM","Zambia"));
completeList.addElement(new CountryData(0x648,"ZW","Zimbabwe"));
}
}

---------------------------------------------------------------------------------