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
Post a Comment