A quick snippet to get CORRECT cell id for Android:
public static int getCID(Context ctx) {
try {
TelephonyManager tm = (TelephonyManager)ctx.getSystemService(Context.TELEPHONY_SERVICE);
GsmCellLocation location = (GsmCellLocation)tm.getCellLocation();
int locationCellid = location.getCid();
int cellId = -1; // set to unknown location by default
if(cellId > 0) { // known location
cellId = locationCellid & 0xffff; // get only valuable bytes
}
return cellId;
} catch (Exception ignored) {}
return -1;
}
This super usefull info was found at: http://groups.google.com/group/android-developers/browse_thread/thread/b8ae536a3ae444f3
Happy location determination! (:
Best regards,
Yahor
0 comments:
Post a Comment