-3

I am a beginner in android developing and I am working on a project to create an app to locate cell phones without using GPS. i got the cell id and the neighboring cell towers now a need how to calculate distance from theses cells to proceed a trilateration in aim to locate my phone using GSM Network

Can anybody help me with how to calculate this for GSM. Any code available for this purpose would be appreciated really.

Thank you all .

1 Answers1

0

Why aren't you using the LocationManager class?

try {
    locationManager = (LocationManager) mContext
            .getSystemService(LOCATION_SERVICE);

    // getting network status
    boolean isNetworkEnabled = locationManager
            .isProviderEnabled(LocationManager.NETWORK_PROVIDER);

    if (!isNetworkEnabled) {
        // no network provider is enabled
    } else {
        // The minimum distance to change Updates in meters
        long MIN_DISTANCE_CHANGE_FOR_UPDATES = 10; // 10 meters

        // The minimum time between updates in milliseconds
        long MIN_TIME_BW_UPDATES = 1000 * 60 * 1; // 1 minute

        // Get location from Network Provider
        locationManager.requestLocationUpdates(
               LocationManager.NETWORK_PROVIDER,
               MIN_TIME_BW_UPDATES,
               MIN_DISTANCE_CHANGE_FOR_UPDATES, this);
        Log.d("Network", "Network");
        if (locationManager != null) {
            location = locationManager
                   .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);
            if (location != null) {
                latitude = location.getLatitude();
                longitude = location.getLongitude();
            }
        }

    }

} catch (Exception e) {
    e.printStackTrace();
}

Further information can be found here: http://www.androidhive.info/2012/07/android-gps-location-manager-tutorial/

LocationManager.NETWORK_PROVIDER

This provider determines location based on availability of cell tower and WiFi access points. Results are retrieved by means of a network lookup.

Docs: https://developer.android.com/reference/android/location/LocationManager.html#NETWORK_PROVIDER

Prexx
  • 2,959
  • 5
  • 31
  • 48
  • **PLEASE DO NOT USE** this terrible androidhive's tutorial ... it is very, very, very bad – Selvin Jun 01 '17 at 11:49
  • There are plenty tutorials in the web. This was the first i found with NETWORK_PROVIDER after a quick search. – Prexx Jun 01 '17 at 11:52
  • @Selvin Why exactly is this so terrible? Can you improve the example in another answer? – Johann Bauer Jun 01 '17 at 12:35
  • Read my comment carefully ... **I wrote about androidhive's so called tutorial** ... [He is misusing the Service class](http://gabesechansoftware.com/location-tracking/) – Selvin Jun 01 '17 at 13:39
  • Thank you , but what i'm looking for is a localisation without using GPS – Mohammed Saidi Jun 03 '17 at 12:25
  • @MohammedSaidi It is without GPS. With the code above you will be located via cell towers and WiFi access points nearby. – Prexx Jun 06 '17 at 06:06