17

I want to get phone serial number by programming to registration configuration of my application and number of users and phones that my app has been installed on them.

Can I get that?

and can I get phone model that my app has been installed on them?

Kara
  • 6,115
  • 16
  • 50
  • 57
Mohsen Bahman
  • 1,092
  • 3
  • 15
  • 27

5 Answers5

60

pls refer this https://stackoverflow.com/a/1972404/951045

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

add READ_PHONE_STATE permission to AndroidManifest.xml

Community
  • 1
  • 1
techieWings
  • 2,045
  • 2
  • 16
  • 18
  • 2
    Context.Telephony_service ---> Context.TELEPHONY_SERVICE – ChangUZ Jun 10 '13 at 08:50
  • u can use: TelephonyManager tManager = (TelephonyManager)myActivity.getSystemService(Context.TELEPHONY_SERVICE); String uid = tManager.getDeviceId(); – Chris Sim Aug 29 '13 at 08:59
  • In case of Android M and above the permissions may not be granted by the user, so we need to check the same before accessing them. Check out this answer http://stackoverflow.com/a/38782876/3811068 – Dhananjay M Nov 21 '16 at 17:32
  • This is deprecated in API 26, please use [`getImei()`](https://developer.android.com/reference/android/telephony/TelephonyManager.html#getimei) – solidak Nov 03 '17 at 14:56
9
public String getIMEI(Context context){

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

}
Damico
  • 1,107
  • 10
  • 5
3

Here is the code:-

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


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



    phoneType = telephonyManager.getPhoneType();
    Log.d(TAG, "getPhoneType () " + phoneType);
Payal
  • 903
  • 1
  • 9
  • 28
0

try this

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

  String deviceid = tm.getDeviceId();
0

Use below code for IMEI:

TelephonyManager tm = (TelephonyManager)getSystemService(TELEPHONY_SERVICE);
String imei= tm.getDeviceId();
Ashish Sahu
  • 1,538
  • 17
  • 22