I’m sure this will have been asked before, but I don’t know what to search for…
Anyway I have an app which I want to behave in a certain way except when being operated by me or on my specific phone – this is for debugging purposes. I can think of all sorts of clumsy ways of doing this, but I suspect there may be a standard way… is there?
EDIT: this code is one possible solution:
TelephonyManager telemamanger = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
String getSimSerialNumber = telemamanger.getSimSerialNumber();
if (getSimSerialNumber.equals("my_serial_number"))
{
// yes its me!
}
The only problem is that it requires an extra permission.
I think that the best way to do this could be by simply using a unique device identifier. It can change or be null in some cases, but since you only need it to make sure that this is YOUR device, you can use it without fearing of some issues.
Here is how to use that(taken from Is there a unique Android device ID?:
You can print that(so you know what the ID of your device is) and later compare it with that result(I’m not sure of the correct if() statement syntax, so I’ll leave that up to you).