Most Android devices can determine their position with some accuracy. This is achieved by using the Global Positioning System (GPS), triangulation from mobile network base stations, or by using open (public) hotspots. To use these features, we need the android.location package.
There are several classes in this package. The most important ones are:
LocationManager — provides access to the system location services, i.e., GPS and others. It also allows you to select the service that best meets your criteria (power consumption, positioning accuracy, etc.)
LocationProvider is an abstract class from which all providers of geographic location information are derived. The provider periodically provides information about changes in geographic coordinates of the device
LocationListener — used to receive notifications from the LocationProvider when coordinates change
Other classes that are worth mentioning are Location (geographical location of the device at a given point in time) and Criteria (criteria for selecting a provider).
In this post, I will focus on getting coordinates from the GPS_PROVIDER provider.
Android… So, it got to me. No, I did not become the happy owner of a shovel-shaped device mistakenly called a “phone” (my old SE K320i is great). It’s much worse than that :-). I had to find out how to develop applications for Android.
After successfully downloading and installing the SDK, I started looking for an IDE. On Android Developers there are two options: Eclipse with the ADT plugin and command line + any editor. I tried this Eclipse… IMHO, it’s an abomination. Firstly, it is terribly slow. So slow that M$ Visual Studio under VirtualBox beats it in terms of responsiveness and convenience. Secondдн, the interface organisation is awful. I have often heard that GIT is for aliens, in this case, Eclipse is not clear who wrote it and for whom :-). You won’t believe me, I spent about 15 minutes trying to find a way to open an existing project. It turns out that you have to import them not open. And the rest, like annoying hints on a quarter of the screen, the inability to change anything in the project properties if there are errors, etc. In short, Eclipse didn’t work for me.
I decided to write the code in Geany and build it manually in the terminal. However, there is also IntelliJ IDEA, which is rumoured to support the Android SDK, but I didn’t bother to try it (maybe for nothing).
P.S. By the way, for me the emulator wouldn’t work on the main X server, failing with
XDM authorization key matches an existing client! SDL init failure, reason is: Couldn't open X11 display
I wasn’t in the mood to look into it, so I just ran it on a separate X server.
Following the news of the successful cross-compilation of QGIS on Android, QGIS was launched on the ASUS Transformer tablet (Android 3.2) and the Samsung Galaxy phone (CyanogenMod 7RC1).
At the moment, QGIS runs without some features (e.g., no Python support, not all providers are available, etc.), but the GUI is fully functional, although there are some problems using it on mobile phones due to the small screen size.
If you want to give it a try, there is a pre-built APK (note that you need to install Ministro and Qt first; the total download size is ~130 MB). There is also a compilation guide on the wiki.
Video of installing and running QGIS on ASUS tablet
Marco Bernasocchi, who is working on porting QGIS to Android at GSoC 2011, reports on a successful cross-compilation of QGIS using the Android NDK r5c.
This was preceded by work on porting all the libraries needed to build QGIS (GDAL, GEOS, Proj, etc). Porting SpatiaLite and optimising the interface for tablets are next on the list.