Reputation: 7937
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.
Upvotes: 1
Views: 88
Reputation: 5062
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?:
import android.provider.Settings.Secure;
private String android_id = Secure.getString(getContext().getContentResolver(),
Secure.ANDROID_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).
Upvotes: 1
Reputation: 4725
You can create a file in SD card, and check the presence of that file. If the file is present, you can assume that it is yours and print extra debugging information etc
Upvotes: 1
Reputation: 2966
Check the phones Id and phone number. Write your own web script to check whether the phone is allowed to access your app. You can use a database for this.
Upvotes: 0