2013-04-17 14 views
0

我知道手机的IMEI可以得到由如何通过检查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,应用程序将被解锁,否则它将停止活动。怎么做?

在此先感谢。

回答

1

尝试这样

long imei=telephonyManager.getDeviceId(); 
if(imei==12345678912345) 
     { 
      //move to next activity 
     } 
else 
{ 
     finish(); 
} 
+0

不知何故它不是为我工作 – Tanzil

+0

你尝试过什么至今。请调试您的代码,然后找出卡住的地方。 – AndroidEnthusiastic

1
long imei=telephonyManager.getDeviceId(); 

if(imei==12345678912345) 

    { 
     Toast.maketext(getapplicationcontext(),"Your device is unlocked",Toast.lengthlong)).show(); 

    } 
else 
{ 
    finish(); 
}