2

使用临时分发(将应用程序作为分包商发送给测试人员或客户)时,有没有办法对您的 Android 应用程序进行代码签名(以允许其仅在具有特定 ID 的设备上打开)?

我知道我可以很容易地共享 apk 文件,但是如果我不希望其他人在应用程序准备好之前重新分发应用程序怎么办?例如,我不希望测试人员能够分发我的应用程序的未完成和错误版本。或者我想向我的客户展示应用程序的最终版本,但在付款之前不允许他们分发它。

4

1 回答 1

4

我做了类似的事情。

以前我得到了测试设备的 IMEI

然后在 onCreate() 函数上

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.
...
...
...
}

更新 :

对于没有电话支持的设备,如平板电脑,使用 TelephonyManager 将获得 null,对于某些设备,最好使用 Secure.ANDROID_ID ...

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);
于 2010-07-16T15:23:33.590 回答