Testing the Application
To test the application, call the displayMap()
function when the "Display map of current location" button is clicked. This is done by adding the code in Listing 3
to the onCreate()
| Author's Note: When you're testing on the emulator, remember that the cell ID and LAC returned by a GsmCellLocation object are not valid (GsmCellLocation always returns a -1 for both the cell ID and LAC). In the above code, the values of Cell ID and LAC are hardcoded.|
Press F11 to test the application on the Android emulator. To display the map of the current location, press the "Display map of current location" button and invoke Google Maps (see Figure 2).
Figure 2. Your Current Location: Google Maps displays the map of the current detected location.
Figure 3. Real-Live View: You can switch Google Maps to Street View mode.
If you are in a location where street view mode is supported, you can also switch to street view (see Figure 3).
Easy and Useful
See how easy it is to obtain the cell ID and LAC of a device using the GsmCellLocation class? More importantly, the Google Maps API provides a way to resolve the cell ID and LAC values into latitude and longitude so that you can obtain the geographical location of a particular user and display the location using a map.