Question

Is there a way to code-sign (to allow it to open only on a device with specific ID) your Android app when using ad-hoc distribution (sending app to testers or clients as a subcontractor)?

I know I can share apk file pretty easily, but what if I don't want other people to redistribute the app before it is ready? I don't want testers to be able to distribute not finished and buggy version of my app for example. Or I would like to show my client the final version of the app, but not allow them to distribute it until the payment is made.

Was it helpful?

Solution

I did something similar.

Previously i get the IMEI of the tester device

and then on the onCreate() function

public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);      

String IMEITesterDevice = "1234123535346453634";

 final TelephonyManager  mTelephony =  (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
    String AndroidDeviceId = mTelephony.getDeviceId();

if (AndroidDeviceId.contentEquals(IMEITesterDevice ) //Not equal then
 super.finish();  //force to finish my app.
...
...
...
}

UPDATE :

for devices without telephony support like tablets you will get null using TelephonyManager, is better to use Secure.ANDROID_ID for some devices...

String AndroidDeviceId;
final TelephonyManager mTelephony = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);//for mobiles
    if (mTelephony.getDeviceId() != null)
        AndroidDeviceId = mTelephony.getDeviceId();
    else // Tablets
        AndroidDeviceId = Secure.getString(
                        getApplicationContext().getContentResolver(),
                        Secure.ANDROID_ID);
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top