使用ad-hoc分发(将应用程序作为分包商发送给测试人员或客户端)时,是否有办法对Android应用进行代码签名(仅允许在具有特定ID的设备上打开)?
我知道我可以很容易地分享apk文件,但是如果我不希望其他人在应用程序准备好之前重新分发应该怎么办?我不希望测试人员能够分发我的应用程序的未完成和有缺陷的版本。或者我想向我的客户展示应用程序的最终版本,但不允许他们在付款之前分发它。
答案 0 :(得分: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);