android cell id -
i cid cell phone , using code :
gsmcelllocation gsmlocation = (gsmcelllocation)telephonymanager.getcelllocation(); int cid = gsmlocation.getcid(); log.e("#############","current cid is: "+cid); int lac = gsmlocation.getlac(); log.e("#############","current lac is: "+lac);
this returns 301 or 6061.
i browsing example codes , found :
/** * seems cid , lac shall in hex. cid should padded zero's * 8 numbers if umts (3g) cell, otherwise 4 numbers. mcc padded 3 * numbers. mnc padded 2 numbers. */ try { // update current location updatelocation(getpaddedhex(cid, cellpadding), getpaddedhex(lac, 4), getpaddedint(mnc, 2), getpaddedint(mcc, 3)); strresult = "position updated!"; } catch (ioexception e) { strresult = "error!\n" + e.getmessage(); } // show info toast results of updatelocation // call. toast t = toast.maketext(getapplicationcontext(), strresult, toast.length_long); t.setgravity(gravity.center_vertical, 0, 0); t.show();}}); } /** * convert int hex string , pad 0's minlen. */ string getpaddedhex(int nr, int minlen) { string str = integer.tohexstring(nr); if (str != null) { while (str.length() < minlen) { str = "0" + str; } } return str; } /** * convert int string , pad 0's minlen. */ string getpaddedint(int nr, int minlen) { string str = integer.tostring(nr); if (str != null) { while (str.length() < minlen) { str = "0" + str; } } return str; }
isn't number gsmcelllocation correct or need alter results shown in example? difference? know documentation cid -1 (unknown) or 0xffff max value, 0xffff 2g or 3g networks?
that code doesn't alter numbers. it's displaying them differently hex or more zeros on left.
Comments
Post a Comment