Advertisement
chayanforyou

Device IMEI

Feb 15th, 2019
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.61 KB | None | 0 0
  1.   /Need Permission
  2.   <uses-permission android:name="android.permission.READ_PHONE_STATE" />
  3.  
  4.   //Global veriable
  5.   private String deviceImei;
  6.  
  7.   //Get device IMEI
  8.   TelephonyManager mTelephonyManager = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
  9.   assert mTelephonyManager != null;
  10.   deviceImei = mTelephonyManager.getDeviceId();
  11.   Log.e(TAG, "IMEI: " + deviceImei);
  12.  
  13.   //Need this checking because some emulator return "---" as IMEI
  14.   if (deviceImei != null && deviceImei.matches("[0-9]+")) {
  15.  
  16.   } else
  17.     Utils.showAlert("Info", "This app doesn't support in your device.", mContext, "Ok");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement