Ada kalanya sebagai seorang developer, kita memperoleh proyek untuk mengembangkan aplikasi dimana aplikasi tersebut hanya tersedia eksklusif bagi pelanggan operator selular tertentu. Bagaimanakah caranya untuk mendeteksi operator selular yang sedang digunakan oleh user? Salah satu solusinya adalah melalui MCC (Mobile Country Code) dan MNC (Mobile Network Code) dari jaringan seluler yang aktif. MNC digunakan dalam kombinasi dengan MCC untuk mengidentifikasi operator selular secara unik.
Berdasarkan data dari Wikipedia, berikut ada MCC dan MNC untuk operator seluler yang ada di Indonesia.
MCC
MNC
Brand
Operator
510 0 PSN PT Pasifik Satelit Nusantara (ACeS)
510 1 INDOSAT PT Indonesian Satellite Corporation Tbk (INDOSAT)
510 3 StarOne PT Indosat Tbk
510 7 TelkomFlexi PT Telkom
510 8 AXIS PT Natrindo Telepon Seluler
510 9 SMART PT Smart Telecom
510 10 Telkomsel PT Telekomunikasi Selular
510 11 XL PT XL Axiata Tbk
510 20 TELKOMMobile PT Telkom Indonesia Tbk
510 21 IM3 PT Indonesian Satellite Corporation Tbk (INDOSAT)
510 27 Ceria PT Sampoerna Telekomunikasi Indonesia
510 28 Fren/Hepi PT Mobile-8 Telecom
510 89 3 PT Hutchison CP Telecommunications
510 99 Esia PT Bakrie Telecom
Beberapa method pada Java ME yang dapat digunakan untuk memperoleh MCC dan MNC adalah sebagai berikut:
public String getIMSI() {
    String out = "";
    try {
            out = System.getProperty("IMSI");
            if (out == null || out.equals("null") || out.equals("")) {
                    out = System.getProperty("phone.imsi");
            }
            if (out == null || out.equals("null") || out.equals("")) {
                    out = System.getProperty("com.nokia.mid.mobinfo.IMSI");
            }
            if (out == null || out.equals("null") || out.equals("")) {
                    out = System.getProperty("com.nokia.mid.imsi");
            }
            if (out == null || out.equals("null") || out.equals("")) {
                    out = System.getProperty("IMSI");
            }
            if (out == null || out.equals("null") || out.equals("")) {
                    out = System.getProperty("imsi");
            }
    } catch (Exception e) {
            return out == null ? e.getMessage() : out;
    }
    return out == null ? "empty" : out;
}

public String getMCC() {
    String out = "";
    try {
        if (out == null || out.equals("null") || out.equals("")) {
            out = System.getProperty("phone.mcc");
        }
        if (out == null || out.equals("null") || out.equals("")) {
            if (out == null || out.equals("null") || out.equals("")) {
                out = System.getProperty("com.sonyericsson.net.mcc");
            }
        }
        if (out == null || out.equals("null") || out.equals("")) {
            out = getIMSI().equals("") ? "" : getIMSI().substring(0, 3);
        }
        if (out == null || out.equals("null") || out.equals(""))
        {
            if (out == null || out.equals("null") || out.equals("")) {
                out = System.getProperty("mcc");
            }
        }
    } catch (Exception e) {
        return out == null ? e.getMessage() : out;
    }
    return out == null ? "empty" : out;
}

public String getMNC(){
    String out = "";
    try{
        if(out== null ||out.equals("null")|| out.equals(""))
            out = System.getProperty("com.nokia.mid.mnc");
        if(out== null ||out.equals("null")|| out.equals(""))
            out = System.getProperty("phone.mnc") ;

        if(out== null ||out.equals("null")|| out.equals(""))
            out = getIMSI().equals("")?"": getIMSI().substring(3,5);

        if(out== null ||out.equals("null")|| out.equals(""))
            out = System.getProperty("com.sonyericsson.net.mnc");

        if(out== null ||out.equals("null")|| out.equals("")){
            out = getIMSI().equals("")?"": getIMSI().substring(3,5);
        }

        if(out== null ||out.equals("null")|| out.equals(""))
            out = System.getProperty("com.samsung.imei");

        if(out== null ||out.equals("null")|| out.equals(""))
            out = System.getProperty("mnc");

    }catch(Exception e){
        return out == null ? e.getMessage() : out;
    }

    return out == null ? "empty" : out;
}
MCC dan MNC tersebut dapat diperoleh pada device yang memiliki Java Runtime 1.0.0 dan setelahnya dengan 3rd party signing. Untuk device sebelum itu, operator / manufacturer domain signing diperlukan agar fungsi ini dapat berjalan.
Semoga bermanfaat!

0 komentar:

Posting Komentar

 
Top
Blogger Template