Login | Register   
LinkedIn
Google+
Twitter
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX


advertisement
 

Location-Based Services Using CellID in Android : Page 3

Though GPS functionality has become hugely popular, it doesn't work indoors and not all devices have built-in GPS receivers. How do you get around this? Learn how to find and use CellID to locate your Android device and use Google maps to display it.


advertisement

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() event handler.

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.



Wei-Meng Lee is a Microsoft MVP and founder of Developer Learning Solutions, a technology company specializing in hands-on training on the latest Microsoft technologies. He is an established developer and trainer specializing in .NET and wireless technologies. Wei-Meng speaks regularly at international conferences and has authored and coauthored numerous books on .NET, XML, and wireless technologies. He writes extensively on topics ranging from .NET to Mac OS X. He is also the author of the .NET Compact Framework Pocket Guide, ASP.NET 2.0: A Developer's Notebook (both from O'Reilly Media, Inc.), and Programming Sudoku (Apress). Here is Wei-Meng's blog.
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap