Save network location in .txt format (without using GPS)

I am starting to program in Android. My graduation project is about tracking a mobile device, and I need a code to save the location (without using GPS) as a text file. Someone offers me codes for this. This will be a big help for me.

+5
source share
2 answers

Try it.

locationManagerNetwork = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    Location location2 = locationManagerNetwork
                    .getLastKnownLocation(LocationManager.NETWORK_PROVIDER);

     if (location2 != null) {       
                String message = String
                        .format("Yout location : \n Longitude: %1$s \n Latitude: %2$s",
                                location2.getLongitude(), location2.getLatitude());
                Toast.makeText(getApplicationContext(), message, Toast.LENGTH_LONG)
                        .show();


    //use here file writer if you want to write the coordinastes in a text file
            }

for recording sd card

File sdcard = Environment.getExternalStorageDirectory();
        File f = new File(sdcard, "/yourfile");

if(!f.exsist()){
f.createNewFile();
//Use outwriter here, outputstream search how to write into a tet file in java code 
}
+2
source

the only way to do this is to play with the telephony manager and see what information you can get about the cell tower or network. Each network tower has a unique identifier, and from this you can get an approximate estimate depending on the signal level and the location of the person.

, .

-1

All Articles