private ArrayList<CellRecord> processNeighbors(final CellRecord serving,final PositionRecord cellPos){
  final ArrayList<CellRecord> neighbors=new ArrayList<>();
  final ArrayList<NeighboringCellInfo> neighboringCellInfos=(ArrayList<NeighboringCellInfo>)mTelephonyManager.getNeighboringCellInfo();
  if (serving == null) {
    Log.e(TAG,"Can't process neighbor cells: we need a serving cell first");
    return neighbors;
  }
  if (neighboringCellInfos == null) {
    Log.i(TAG,"Neigbor cell list null. Maybe not supported by your phone..");
    return neighbors;
  }
  for (  final NeighboringCellInfo ci : neighboringCellInfos) {
    final boolean skip=!isValidNeigbor(ci);
    if (!skip) {
      final CellRecord neighbor=new CellRecord(mSessionId);
      neighbor.setOpenBmapTimestamp(cellPos.getOpenBmapTimestamp());
      neighbor.setBeginPosition(cellPos);
      neighbor.setEndPosition(cellPos);
      neighbor.setIsServing(false);
      neighbor.setIsNeighbor(true);
      neighbor.setMnc(serving.getMnc());
      neighbor.setMcc(serving.getMcc());
      neighbor.setOperator(serving.getOperator());
      neighbor.setOperatorName(serving.getOperatorName());
      final int networkType=ci.getNetworkType();
      neighbor.setNetworkType(networkType);
      if (networkType == TelephonyManager.NETWORK_TYPE_GPRS || networkType == TelephonyManager.NETWORK_TYPE_EDGE) {
        neighbor.setIsCdma(false);
        neighbor.setLogicalCellId(ci.getCid());
        neighbor.setArea(ci.getLac());
        neighbor.setStrengthdBm(-113 + 2 * ci.getRssi());
        neighbor.setStrengthAsu(ci.getRssi());
      }
 else       if (networkType == TelephonyManager.NETWORK_TYPE_UMTS || networkType == TelephonyManager.NETWORK_TYPE_HSDPA || networkType == TelephonyManager.NETWORK_TYPE_HSUPA || networkType == TelephonyManager.NETWORK_TYPE_HSPA) {
        neighbor.setIsCdma(false);
        neighbor.setPsc(ci.getPsc());
        neighbor.setStrengthdBm(ci.getRssi());
        final int asu=(int)Math.round((ci.getRssi() + 113.0) / 2.0);
        neighbor.setStrengthAsu(asu);
      }
 else       if (networkType == TelephonyManager.NETWORK_TYPE_CDMA) {
        neighbor.setIsCdma(true);
      }
      neighbors.add(neighbor);
    }
  }
  return neighbors;
}

private ArrayList < CellRecord > processNeighbors ( final CellRecord serving , final PositionRecord cellPos ) { final ArrayList < CellRecord > neighbors = new ArrayList < > ( ) ; final ArrayList < NeighboringCellInfo > neighboringCellInfos = ( ArrayList < NeighboringCellInfo > ) mTelephonyManager . getNeighboringCellInfo ( ) ; if ( serving == null ) { Log . e ( TAG , "Can't process neighbor cells: we need a serving cell first" ) ; return neighbors ; } if ( neighboringCellInfos == null ) { Log . i ( TAG , "Neigbor cell list null. Maybe not supported by your phone.." ) ; return neighbors ; } for ( final NeighboringCellInfo ci : neighboringCellInfos ) { final boolean skip = ! isValidNeigbor ( ci ) ; if ( ! skip ) { final CellRecord neighbor = new CellRecord ( mSessionId ) ; neighbor . setOpenBmapTimestamp ( cellPos . getOpenBmapTimestamp ( ) ) ; neighbor . setBeginPosition ( cellPos ) ; neighbor . setEndPosition ( cellPos ) ; neighbor . setIsServing ( false ) ; neighbor . setIsNeighbor ( true ) ; neighbor . setMnc ( serving . getMnc ( ) ) ; neighbor . setMcc ( serving . getMcc ( ) ) ; neighbor . setOperator ( serving . getOperator ( ) ) ; neighbor . setOperatorName ( serving . getOperatorName ( ) ) ; final int networkType = ci . getNetworkType ( ) ; neighbor . setNetworkType ( networkType ) ; if ( networkType == TelephonyManager . NETWORK_TYPE_GPRS || networkType == TelephonyManager . NETWORK_TYPE_EDGE ) { neighbor . setIsCdma ( false ) ; neighbor . setLogicalCellId ( ci . getCid ( ) ) ; neighbor . setArea ( ci . getLac ( ) ) ; neighbor . setStrengthdBm ( - 113 + 2 * ci . getRssi ( ) ) ; neighbor . setStrengthAsu ( ci . getRssi ( ) ) ; } else if ( networkType == TelephonyManager . NETWORK_TYPE_UMTS || networkType == TelephonyManager . NETWORK_TYPE_HSDPA || networkType == TelephonyManager . NETWORK_TYPE_HSUPA || networkType == TelephonyManager . NETWORK_TYPE_HSPA ) { neighbor . setIsCdma ( false ) ; neighbor . setPsc ( ci . getPsc ( ) ) ; neighbor . setStrengthdBm ( ci . getRssi ( ) ) ; final int asu = ( int ) Math . round ( ( ci . getRssi ( ) + 113.0 ) / 2.0 ) ; neighbor . setStrengthAsu ( asu ) ; } else if ( networkType == TelephonyManager . NETWORK_TYPE_CDMA ) { neighbor . setIsCdma ( true ) ; } neighbors . add ( neighbor ) ; } } return neighbors ; }
returns an array list with neighboring cells please note : 1 ) not all cell phones deliver neighboring cells ( e . g . samsung galaxy ) 2 ) if in 3g mode , most devices won ' t deliver cell ids
