2013-02-02 18 views
17

Desidero ottenere il numero di serie del telefono programmando la configurazione di registrazione della mia applicazione e il numero di utenti e telefoni su cui è stata installata la mia app.Come ottenere il numero di serie del telefono (IMEI)

Posso ottenerlo?

e posso ottenere il modello del telefono su cui è stata installata la mia app?

+1

per ottenere il numero IMEI utilizzare questo codice 'TelephonyManager mngr = getSystemService (Context.Telephony_service); mngr.getDeviceId() ' – techieWings

+0

quali autorizzazioni sono necessarie? –

+0

READ_PHONE_STATE – techieWings

risposta

60

pls si riferiscono questa https://stackoverflow.com/a/1972404/951045

TelephonyManager mngr = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE); 
    mngr.getDeviceId(); 

aggiungere READ_PHONE_STATE permesso di AndroidManifest.xml

+2

Context.Telephony_service ---> Context.TELEPHONY_SERVICE – ChangUZ

+0

u può utilizzare: TelephonyManager tManager = (TelephonyManager) myActivity.getSystemService (Context.TELEPHONY_SERVICE); String uid = tManager.getDeviceId(); –

+0

In caso di Android M e versioni successive, le autorizzazioni potrebbero non essere concesse dall'utente, quindi è necessario verificare lo stesso prima di accedervi. Dai un'occhiata a questa risposta http://stackoverflow.com/a/38782876/3811068 –

3

Ecco il codice: -

telephonyManager = (TelephonyManager)context.getSystemService(Context.TELEPHONY_SERVICE); 


    deviceId = telephonyManager.getDeviceId(); 
    Log.d(TAG, "getDeviceId() " + deviceId); 



    phoneType = telephonyManager.getPhoneType(); 
    Log.d(TAG, "getPhoneType() " + phoneType); 
0

provare questo

final TelephonyManager tm =(TelephonyManager)getBaseContext().getSystemService(Context.TELEPHONY_SERVICE); 

    String deviceid = tm.getDeviceId(); 
9
public String getIMEI(Context context){ 

    TelephonyManager mngr = (TelephonyManager) context.getSystemService(context.TELEPHONY_SERVICE); 
    String imei = mngr.getDeviceId(); 
    return imei; 

} 
0

Usa sotto il codice IMEI per:

TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE); 
String imei= tm.getDeviceId(); 
Problemi correlati