My first map, the Google Map View
Posted by Fredde in Google Maps, Misc programming on October 11, 2010
In the previous post I mentioned the tutorial “Hello, Views” on http://developer.android.com, and one step handling the Map View. I had to try it out and it was rather straight forward. I bumped into some small problems on the way, and I’ll try to sort them out below. By the way, the “Google Map View” tutorial is found here.
The first thing to do before doing the coding part of this is to install the needed packages, if you didn’t do that in the Environment Setup part. This is rather straight forward by adding the Google API’s add-ons via Android SDK and AVD Manager in Eclipse. I decided to install all packages from Google, even the obsolete packages.
When the installation of the Google API’s add-ons is done, just get on following the steps in the tutorial creating a new project pointing out one of the Google API’s project build targets instead of the regular Android targets. After that it is really important to add the following line in the AndroidManifest.xml file, as a child node of the application node:
<uses-library android:name="com.google.android.maps" />
The next thing to add in the XML file is the following, as a child of the manifest node:
<uses-permission android:name="android.permission.INTERNET" />
This gave me the following AndroidManifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="se.freddes.helloworldgooglemaps"
android:versionCode="1"
android:versionName="1.0">
<uses-permission android:name="android.permission.INTERNET" />
<application ...>
<activity ...>
.
.
.
</activity>
<uses-library android:name="com.google.android.maps" />
</application>
</manifest>
The two important lines of code are found on line 7 and 17.
The next important step, which caused me some problems, was to obtain a Google Maps API key. This is done here, Obtaining a Maps API Key. I decided to request for an SDK Debug Certificate based key. The key has to be entered in the main.xml in the layout project folder, file as an attribute on the MapView node:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.maps.MapView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/mapview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:clickable="true"
android:apiKey="0KXXXXXXXXQ7m-VUPPXXXXXXXXXbF8A"
/>
After this is done, just follow the tutorial to the end and be amazed by the way the Google Maps is integrated in the app. I found it really easy to add map overlays, zooming and panning etc.
Next up for me is the Notepad three step tutorial, with handling databinding and other goodies…
Hello World!
Posted by Fredde in Misc programming on October 9, 2010
After setting up the development environment before, it is now time to have a go on actually programming some stuff, e.g. a Hello World app to be more accurate.
I decided to follow the tutorials on Android Developers site, starting with the basic Hello World thing here.
The first Hello [something] began with creating an AVD (Android Virtual Device) for the app to run on. It is easily done using the AVD Manager that comes with the Eclipse plugin installed before. I decided to create have a go with the same platform version as the HTC Hero was running. The platform version is not yet important, so just kick off using the one suggested in the tutorial.
After creating and launching the AVD, it takes a while to start so just let it start up while going on to the next step in the tutorial, e.g. creating a New Android Project.
Before going on to the coding part of the tutorial, have a close look at the project structure created. The structure looks different depending on which version of the platform chosen when creating the project.
After creating the project it’s just a matter of following the tutorial to the very end. It will cover the important stuff for a newbie:
- The Activity class
- Programmatically create a UI
- Constructing a UI using the XML layout
- App resources, such as text to be presented in the UI
- Running the app in the AVD created earlier
- Debugging the app
Last up it has a short description on how to create a project not using Eclipse IDE, but that part I skipped. Let me get all the help I can get, meaning stay inside the Eclipse IDE and the plugins installed there.
Next up are more tutorials, covering the views, localization, testing and a three step tutorial creating a Notepad app:
- Hello, Views
- Hello, L10N (localization)
- Hello, Testing
I won’t write about those tutorials here, just work them through with the exception for the Google Maps part of the Hello Views. Next up after that is the Notepad three step tutorial!
Setting up the dev environment
Posted by Fredde in Environment on October 8, 2010
A good start when developing software is to set up the environment to be used. In the Android development case it’s no different. I started off by downloading the following stuff:
The JDK is needed by the Android SDK. I decided to download the Java EE version of Eclipse after I had studied the version comparison sheet. I guess the classic version is enough but the Java EE version felt good for me. A great feature with Eclipse is the possibility to just download a zip file, extract it and execute the eclipse.exe in the Eclipse root folder.
These three downloads are of course listed on the Android SDK Quick Start page.
After downloading and installing the above software bundles I fired up Eclipse and installed the ADT (Android Development Tools) Plugins, via Help -> Install New Software and enter https://dl-ssl.google.com/android/eclipse/ in the Work with text area. Just select everything listed in list box showing available software and finish the installation. The ADT will add a new toolbar button (
) where you can manage your virtual devices, e.g. Android emulators for different Android OS versions. I decided to install all versions available, from version 1.1 up to 2.2, even the versions marked as obsolete.
After installing the ADT Plugins your somewhat ready to start the development. OK where to start? Since I’m a newbie, let’s start with the basics: a “Hello World” thingy! It’s found here, but I will write about the in the next post.
Android development dummy
The other day I bought an “old” Android phone, an HTC Hero. I have another one from work, so now when owning my own only to use as a toy, I had no excuses not to learn the Android SDK and maybe develop some kind of useful app.
Of course, as the nerd I am, I had to start a new blog about it. Now I’m at an “Android SDK for dummies” level, but hopefully there will be some evolving of knowledge showing in the following posts here. How does that sound? Great, isn’t it? Let’s get it goin’!