For a while I tried to get CellID and LAC of nearby base stations. Unfortunately, I did not succeed. First option:
GsmCellLocation xXx = new GsmCellLocation(); CID = xXx.getCid(); LAC = xXx.getLac(); Toast output = Toast.makeText(getApplicationContext(), "Base station LAC is "+LAC+"\n" +"Base station CID is " +CID, Toast.LENGTH_SHORT); output.show();
But in this case, I get a -1 value (as I understand it, this means that it is not GSM, but when I check with isGSM, it shows "true"). Another way I found surfing the net (I updated it a bit)
public void GetID(){ List<NeighboringCellInfo> neighCell = null; TelephonyManager telManager = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE); neighCell = telManager.getNeighboringCellInfo(); for (int i = 0; i < neighCell.size(); i++) { try { NeighboringCellInfo thisCell = neighCell.get(i); int thisNeighCID = thisCell.getCid(); int thisNeighRSSI = thisCell.getRssi(); log(" "+thisNeighCID+" - "+thisNeighRSSI); } catch (NumberFormatException e) { e.printStackTrace(); NeighboringCellInfo thisCell = neighCell.get(i); log(neighCell.toString()); } } }
But in this case, the application simply crashes immediately after clicking the execute button. Eclipse does not show errors. Maybe someone has ideas on how to fix my problems?
Logcat says: 10-05 22: 53: 27.923: ERROR / dalvikvm (231): cannot open stack trace file '/data/anr/traces.txt': permission denied
Permissions Used:
<uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" /> <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> <uses-permission android:name="android.permission.SEND_SMS"></uses-permission> <uses-permission android:name="android.permission.RECEIVE_SMS"></uses-permission> <uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES" />
Perhaps the problem is that I forgot to include:
TelephonyManager telManager = ( TelephonyManager )getSystemService(Context.TELEPHONY_SERVICE);
Update I turned on the line above, the accident disappeared, but now when I press the button, nothing happens. Updated source code.
java android
StalkerRus
source share