![]() ![]() obtain the location provider reference, a LocationProvider instance, using previous defined criteria and use it to query the GPS module for the current location the getLocation() method has a timeout parameter indication how long we are willing to wait (seconds) for the data.create a instance, used to select the location provider although there are multiple options (described by the JSR-179 documentation), their default values are the least restrictive in this example we choose explicitly to allow a cost for the service (it’s free) and we don’t have a power consumption requirement this step is not so important because the device has one GPS module and these are the criteria for selecting between multiple modules ĬtPreferredPowerConsumption(Criteria.NO_REQUIREMENT).In order to communicate with the phone GPS module and get data regarding coordinates, course, altitude or speed we need classes from .* package: How to use J2ME Location API (JSR-179) and get the GPS coordinates uses the Bluetooth API (JSR 82) to discover and to connect to the external GPS module.In this case, you need another solution (I will post it in another article) that If you have a mobile device that doesn’t have a GPS incorporated, this solution will not work because the J2ME Location API doesn’t have methods for connecting through Bluetooth to that external module. ![]() You can download the full source code, including a sample test MIDlet. The application can be tested on the emulator or on a real device that has a GPS module incorporated. In this article it is described and developed a fully MIDlet application that gets coordinates from the mobile device GPS module and use them to display a Google static map for that location. The later is accessible through Google Static Maps API V2, which is an open and free service (no longer requires a Maps API key) and more efficient as it minimizes network transfers. Also mobile applications integrate location based services and one increasingly used it to provide maps images using Google Maps or Google Static Maps. These devices come with support for the Location API for J2ME under JSR-179 that allow J2ME MIDlets applications to query the GPS module for geo-location coordinates. Today, most mobile devices come with a GPS module or can connect to one using Bluetooth services. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |