CHAPTER 33

Accessing Location‑Based Services

 

A popular feature on current‑era mobile devices is GPS capability, so the device can tell you where you are at any point in time. While the most popular use of GPS service is mapping and directions, there are other things you can do if you know your location. For example, you might set up a dynamic chat application where the people you can chat with are based on physical location, so you’re chatting with those you are nearest. Or you could automatically geotag posts to Twitter or similar services.

GPS is not the only way a mobile device can identify your location. Alternatives include the following:

• The European equivalent to GPS, called Galileo, which is still under development at the time of this writing

• Cell‑tower triangulation, where your position is determined based on signal strength to nearby cell towers

• Proximity to public WiFi “hotspots” that have known geographic locations

Android devices may have one or more of these services available to them. You, as a developer, can ask the device for your location, plus details on what providers are available. There are even ways for you to simulate your location in the emulator, for use in testing your location‑enabled applications.

 

Location Providers: They Know Where You’re Hiding

 

Android devices can have access to several different means of determining your location. Some will have better accuracy than others. Some may be free, while others may have a cost associated with them. Some may be able to tell you more than just your current position, such as your elevation over sea level, or your current speed.

Android, therefore, has abstracted all this out into a set of objects. Your Android environment will have zero or more instances, one for each distinct locating service that is available on the device. Providers know not only your location, but their own characteristics, in terms of accuracy, cost, etc.

You, as a developer, will use a , which holds the set, to figure out which is right for your particular circumstance. You will also need the permission in your application, or the various location APIs will fail due to a security violation. Depending on which location providers you wish to use, you may need other permissions as well, such as or .

 








Дата добавления: 2015-05-16; просмотров: 681;


Поиск по сайту:

При помощи поиска вы сможете найти нужную вам информацию.

Поделитесь с друзьями:

Если вам перенёс пользу информационный материал, или помог в учебе – поделитесь этим сайтом с друзьями и знакомыми.
helpiks.org - Хелпикс.Орг - 2014-2024 год. Материал сайта представляется для ознакомительного и учебного использования. | Поддержка
Генерация страницы за: 0.006 сек.