java - why this code not working for IMEI call over android? -


i want make code imei phone , check given data (12345678912345). if match it'll call onsearchrequested();

here code

long imei=telephonymanager.getdeviceid(); if(imei==12345678912345)          {             onsearchrequested();         } else {          finish(); } 

here if(imei==12345678912345) not working on eclipse. i've used

<uses-permission android:name="android.permission.read_phone_state" /> permission. 

try below

 string mimei = null;   telephonymanager mtelemanager = null;   mtelemanager = (telephonymanager) this.getsystemservice(context.telephony_service);   //here refers activity context  if(mtelemanager!=null){   mimei = mtelemanager.getdeviceid(); //get imei number  } 

then

  if(mimei.equals("12345678912345"))   {         onsearchrequested();   }   else   {      finish();   } 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -