I try to comparing the IMEI code and a string
public static String getDeviceIMEI(Context context) {
if (ActivityCompat.checkSelfPermission(context, Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
}
String identifier = null;
TelephonyManager tm = (TelephonyManager) context.getSystemService(Context.TELEPHONY_SERVICE);
if (tm != null)
identifier = tm.getDeviceId();
if (identifier == null || identifier.length() == 0)
identifier = Settings.Secure.getString(context.getContentResolver(), Settings.Secure.ANDROID_ID);
return identifier;
}
this method calculate the IMEI code of the device, it return a String with the code. And this method compare the 2 string:
private boolean checkIMEI() {
if (Device.getDeviceIMEI(SplashScreenActivity.this) == "xxx")
return true;
else
return false;
}
("xxx" is the personal IMEI address of my device)
But when I run it on the device, the method checkIMEI() returns to me false... I don't have any kind of idea to solve the problem. Thanks for helping