In my application I used to lock application with IMEI code. I mean during startup application checks device IMEI and compares it with list of allowed devices. If device is in list user can continue to work, otherwise it bails out:
public boolean checkIMEI(Activity activity)
{
TelephonyManager tm=(TelephonyManager )activity.getSystemService(Context.TELEPHONY_SERVICE);
if(tm==null)
{
Log.v(TAG, "Can't get telephony service");
new MessageBox(activity, "Can't get telephony service. Forcing shut down!");
return false;
}
//encrypted IMEIs list
String[] vals=activity.getResources().getStringArray(R.array.imeis);
//real device IMEI
String deviceId=tm.getDeviceId();
if(deviceId==null || deviceId.length() < 2)
{
Log.v(TAG, "Looks like emulator - bail out!");
Toast.makeText(activity, "This special version not intended to run in this device!", 5000).show();
return false;
}
boolean valid=false;
for(String val:vals)
{
String imei=Checker.decryptTemp(val); //decrypt IMEIs
if(imei.equalsIgnoreCase(deviceId))
{
valid=true;
break;
}
}
if(!valid)
{
Log.v(TAG, "Invalid device IMEI!");
return false;
}
return true;
}
Problem with Android tablets not equipped with telephony service. So these devices don't have IMEI. On which id should I rely upon? Mac address or something else? Also each time I need to ask prospective users send me their device id... How they can do it?