Friday, July 19, 2013

Java library for retrieving SMS email gateway, mms APN settings

At the time of this post, there is currently no library written in Java for retrieving the SMS email gateways of mobile service providers, or mms APN settings given an mcc/mnc pair, or Country code and operator name. This library uses a comprehensive aggregation of mms APN settings, MCC, MNC, Operator/Carrier names, SMS email gateways, and MMS email gateways from many online sources (xda developers , cm10.1 apns-config, Wikipedia  mobile country code page, and other sms email gateways found online).

Here is the final xml: XML

Here is a download for the library: Droidprism.jar
Javadoc:    Carrier.html    APN.html

First add Jsoup to the build path.

import com.droidprism.*;

Carrier c = Carrier.getCarrier("US","Verizon");
if(c != null) {
  String smsemail = c.getsmsemail();  
  String mmsemail = c.getmmsemail();
  System.out.println(smsemail + "   " + mmsemail); 
  com.droidprism.APN apn = c.getAPN();
  if(apn != null) {
     String mmsc = apn.mmsc;
     String mmsproxy = apn.proxy; //"" if none
     String mmsport = apn.port; //0 if none
     System.out.println(mmsc +"  " + mmsproxy + "  " + mmsport); 
     //prints   0

You can also get the carrier from android with mcc and mnc codes:
TelephonyManager tel = (TelephonyManager) 
    String networkOperator = tel.getNetworkOperator();

    if (networkOperator != null) {
        int mcc = Integer.parseInt(
                  networkOperator.substring(0, 3));
        String s = networkOperator.substring(3);
        //remove leading zeroes
        int mnc = Integer.parseInt(
        Carrier c = Carrier.getCarrier(mcc, mnc);
        APN a = c.getAPN(); 


  1. I added the .jar file to my project but am getting this error at the line that instantiates the Carrier object :

    java.lang.NoClassDefFoundError: com.droidprism.Carrier

  2. add Jsoup to the build path, import com.droidprism.*; If this is in android, first import the jars to the libs directory, then configure build path -> add jars -> select the jars from the libs directory, then configure build path ->order and export -> check off the jars, and click up so that jsoup and droidprism are at the top

  3. Carrier.getCarrier(mcc, mnc);

    is extremely slow (30 seconds or so) - Verizon Galaxy Nexus.

    Is this an issue for anyone else?

  4. yes i am experiencing the same response time or even longer than 30 seconds for the getCarrier call on a Nexus 5.

  5. this is the repo.the code is there.