我知道手机IMEI可以通过
获取 TelephonyManager telephonyManager = (TelephonyManager)getSystemService(Context.TELEPHONY_SERVICE);
telephonyManager.getDeviceId();
我找到了试用版的定时炸弹代码,它给了我一个新的想法。那段代码是 -
protected void onResume()
{
super.onResume();
Calendar expirationDate = Calendar.getInstance();
expirationDate.set(2009, 7, 3); //hardcoded expiration date
Calendar t = Calendar.getInstance(); //Calendar with current time/date
if (t.compareTo(expirationDate) == 1)
finish();
}
现在我想制作一个可以检查IMEI的代码。如果IMEI是123456789123456,则应用程序将被解锁,否则将停止活动。怎么做?
提前致谢。
答案 0 :(得分:1)
试试这个
long imei=telephonyManager.getDeviceId();
if(imei==12345678912345)
{
//move to next activity
}
else
{
finish();
}
答案 1 :(得分:1)
long imei=telephonyManager.getDeviceId();
if(imei==12345678912345)
{
Toast.maketext(getapplicationcontext(),"Your device is unlocked",Toast.lengthlong)).show();
}
else
{
finish();
}