1
I’m needing to get a unique identifier for my app, I’m trying to get the device IMEI and I’m not getting, below follows the code I tried to get the IMEI and it always stops at the first if that has the return "imei error";
Method to obtain the IMEI
public String obterImei() {
String imeinum = "huhu";
TelephonyManager tm = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
if (ActivityCompat.checkSelfPermission(this, android.Manifest.permission.READ_PHONE_STATE) != PackageManager.PERMISSION_GRANTED) {
// TODO: Consider calling
// ActivityCompat#requestPermissions
// here to request the missing permissions, and then overriding
// public void onRequestPermissionsResult(int requestCode, String[] permissions,
// int[] grantResults)
// to handle the case where the user grants the permission. See the documentation
// for ActivityCompat#requestPermissions for more details.
return "imei error";
}else{
imeinum = tm.getDeviceId();
return imeinum;
}
}
Method call:
String imei = obterImei();
It is possible to get the IMEI of Android 10 (Q)?
– Marcelo Gomes
guy I don’t think
– jallisson jallis oliveira band