I recently got a new HTC Desire phone. One of the main reasons for purchasing an Android phone was the ability to write and deploy my own applications to it. Just prior to getting the phone I had seen a post from Google regarding the new App Inventor for Android tool. The tool is in beta at this time so I signed up hoping that I would get an invite and I would be try out this new tool. Last week I got the invite and started playing with App Inventor.
As I am interested in GPS and location aware applications I decided to develop a small application that would show the current location, current address and the option to launch the Google Maps application on the phone.
The Android App Inventor is a web application that has a visual GUI builder to create the GUI and uses 'blocks' in place of code to provide the logic in the application.
The screenshot below shows the GUI builder with the 4 controls used to display the current latitude and longitude and the street address if known from the Google geocoding service. It also has a button to initiate the display of a Google map centered on the current co-ordinates.
To obtain the GPS co-ordinates you will need to add a LocationSensor to the non-visible components. This sensor allows you to access the built-in GPS on Android devices. It includes methods to enable/disable the internal location sensor, read the sensors and get the current address.
To obtain the GPS co-ordinates you will need to add a LocationSensor to the non-visible components. This sensor allows you to access the built-in GPS on Android devices. It includes methods to enable/disable the internal location sensor, read the sensors and get the current address.
It also shows the logic for the ActivityStarter to create and display a Google Map. Information on how to setup the properties for the Google Maps ActivityStarter is in the MapTour tutorial.
Once the properties are configured you will need to generate the URI to pass to the Map Activity. I have shown this above as it took a couple of attempts to get this right. As it is not currently possible to simulate the location sensor in App Inventor the app will need to be compiled and deployed to either the Android SDK emulator or a real phone.I did this a number of times prior to getting it to work.
I hope this information helps if you are trying to use LocationSensor and Google Maps activities on App Inventor.
I have added a link to the source code here.
My other App Inventor tutorials are here:
App Inventor - Lists
App Inventor - SMS Services