开发者

Android app ad-hoc distribution and code signing ( detecting UID )

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.


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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜