title: Retrieve cell towers information
body: <p>Does anybody know how to retrieve cell tower list on GSM and CDMA on Android.</p>
  
  <p>I have been trying to use Google Maps Locations API:
  <a href="https://developers.google.com/maps/documentation/business/geolocation/">https://developers.google.com/maps/documentation/business/geolocation/</a></p>
  
  <p>And I want to get cell towers information with these fields:</p>
  
  <ul>
  <li>cellId: Unique identifier of the cell. On GSM, this is the Cell ID (CID); CDMA networks use the Base Station ID (BID).</li>
  <li>locationAreaCode: The Location Area Code (LAC) for GSM networks; CDMA networks use Network ID (NID).</li>
  <li>mobileCountryCode: The cell tower's Mobile Country Code (MCC).</li>
  <li>mobileNetworkCode: The cell tower's Mobile Network Code. This is the MNC for GSM, or the System ID (SID) for CDMA.</li>
  <li>age: The number of milliseconds since this cell was primary. If age is 0, the cellId represents a current measurement.</li>
  <li>signalStrength: Radio signal strength measured in dBm.</li>
  <li>timingAdvance: The timing advance value.</li>
  </ul>
  
  <hr>
  
  <p>This code doesn't especially getting cell towers information.</p>
  
  <pre><code>TelephonyManager tel = (TelephonyManager) getSystemService(Context.TELEPHONY_SERVICE);
  
  // Type of the network
  int phoneTypeInt = tel.getPhoneType();
  String phoneType = null;
  phoneType = phoneTypeInt == TelephonyManager.PHONE_TYPE_GSM ? "gsm" : phoneType;
  phoneType = phoneTypeInt == TelephonyManager.PHONE_TYPE_CDMA ? "cdma" : phoneType;
  try {
    if (phoneType != null) {
      params.put("radioType", phoneType);
    }
  } catch (Exception e) {}
  
  /*
   * The below code doesn't work I think.
   */
  JSONArray cellList = new JSONArray();
  List&lt;NeighboringCellInfo&gt; neighCells = tel.getNeighboringCellInfo();
  for (int i = 0; i &lt; neighCells.size(); i++) {
    try {
      JSONObject cellObj = new JSONObject();
      NeighboringCellInfo thisCell = neighCells.get(i);
      cellObj.put("cellId", thisCell.getCid());
      cellList.put(cellObj);
    } catch (Exception e) {}
  }
  if (cellList.length() &gt; 0) {
    try {
      params.put("cellTowers", cellList);
    } catch (JSONException e) {}
  }
  </code></pre>
  
  <p>And I set permissions like this:</p>
  
  <pre><code>&lt;uses-permission android:name="android.permission.READ_PHONE_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_COARSE_UPDATES"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/&gt;
  &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
  </code></pre>
  
  <p>Please help me, thank you.</p>