How to extract the numeric IMEI as shown on the phone when doing * # 06 # from my application [duplicated]

1

I have the method well implemented to extract the imei in my application. The issue is that it shows me the imei: 52b3f8b114ff321f and what I need is the numeric format like 35232143423546.

    
asked by Zanax Lobartis 31.08.2017 в 19:54
source

1 answer

1

Try using the getDeviceId () method of the TelephonyManager class, which returns a String with the IMEI for the GSM network. Do not forget to declare in the Manifiest the permission to be able to read the telephone information.

<uses-permission android:name="android.permission.READ_PHONE_STATE" />

I leave a link to the android documentation to know about the TelephonyManager class .

An example to implement outside the main thread:

public String obtenerIMEI(Context context){
        TelephonyManager tm = (TelephonyManager)context.getSystemService(TELEPHONY_SERVICE);
        return tm.getImei();
}

This function returns a String with the IMEI and it would be called like this:

obtenerIMEI(getApplicationContext());
    
answered by 31.08.2017 / 20:14
source