如何使用手机信号塔查找用户的位置?如何使用、手机信号、位置、用户

2023-09-12 23:49:52 作者:Painfullove(痛爱)

如何使用手机信号塔在Android中找到用户位置,或者如何基于Android中的小区ID获取单元位置?

解决方案

 类MyLocationActivity
     扩展MapActivity {
    MapController mapController;
    MyPositionOverlay positionOverlay;
    @覆盖
    公共无效的onCreate(包savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
        图形页面图形页面=(图形页面)findViewById(R.id.mapview);
        mapController = mapView.getController();
        //配置图的显示选项
        mapView.setSatellite(真正的);
        mapView.setStreetView(真正的);
        mapView.displayZoomControls(假);
        mapController.setZoom(17);
        //添加MyPositionOverlay
        positionOverlay =新MyPositionOverlay();
        名单<覆盖>叠加=调用MapView.getOverlays();
        overlays.add(positionOverlay);
        LocationManager locationmanager;
        字符串情形= Context.LOCATION_SERVICE;
        locationmanager =(LocationManager)getSystemService(上下文);
        字符串提供商= LocationManager.NETWORK_PROVIDER;
        位置位置= locationmanager.getLastKnownLocation(供应商);
        updateWithNewLocation(位置);
    }
    私人无效updateWithNewLocation(位置定位){
        如果(位置!= NULL){
            positionOverlay.setLocation(位置);
            双纬度= location.getLatitude()* 1E6;
            双LON = location.getLongitude()* 1E6;
            的GeoPoint点=新的GeoPoint(lat.intValue(),lon.intValue());
            mapController.animateTo(点);
        }
        其他{


        }

    }

    @覆盖
    保护的布尔isRouteDisplayed(){
        // TODO自动生成方法存根
        返回false;
    }
}
 

How to find the user location using the cell tower in Android, or how to get the cell location based on the Cell ID in Android?

解决方案 我的oppo手机信号不好,经常没信号是什么原因

class MyLocationActivity
     extends MapActivity {
    MapController mapController;
    MyPositionOverlay positionOverlay;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        MapView mapView = (MapView) findViewById(R.id.mapview);
        mapController = mapView.getController();
        // Configure the map display options
        mapView.setSatellite(true);
        mapView.setStreetView(true);
        mapView.displayZoomControls(false);
        mapController.setZoom(17);
        // Add the MyPositionOverlay
        positionOverlay = new MyPositionOverlay();
        List<Overlay> overlays = mapView.getOverlays();
        overlays.add(positionOverlay);
        LocationManager locationmanager;
        String context=Context.LOCATION_SERVICE;
        locationmanager=(LocationManager) getSystemService(context);
        String provider=LocationManager.NETWORK_PROVIDER;
        Location location= locationmanager.getLastKnownLocation(provider);
        updateWithNewLocation(location);
    }
    private void updateWithNewLocation(Location location) {
        if(location!=null){
            positionOverlay.setLocation(location);
            Double lat=location.getLatitude()*1E6;
            Double lon=location.getLongitude()*1E6;
            GeoPoint point = new GeoPoint(lat.intValue(),lon.intValue());
            mapController.animateTo(point);
        }
        else{


        }

    }

    @Override
    protected boolean isRouteDisplayed() {
        // TODO Auto-generated method stub
        return false;
    }
}