android - The application stops running when executing getLac(),getCellId() -


this code,i cant able value of cellid , lac value.this code,

public class lac extends activity {     private int mcid ;     private int mlac ;     gsmcelllocation location;     @override     public void oncreate(bundle savedinstancestate) {         super.oncreate(savedinstancestate);         setcontentview(r.layout.main);      telephonymanager tel=(telephonymanager)getsystemservice(context.telephony_service);     location = (gsmcelllocation) tel.getcelllocation();          mlac=location.getlac();         mcid=location.getcid();         toast.maketext(getapplicationcontext(),"lac="+mlac+"cellid="+mcid+type,toast.length_long).show();     }      } 

when run emulator says application stops running unexpectedly.i used permission (access_coarse_location),(access_fine_location).

mlac=location.getlac(); 

i sure returning null (-1) , getting nullpointerexception because gsm location area code unknown, try running on device instead of emulator.


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -