My first learning log for developing android apps
I followed the rave short course instructions, it took a few hours to download and install Eclipse, Android ADT plugin and SDK, I managed to set the environment up with ease.
I then created a hello world application, by following the tutorial this gave me an understanding of running an app the structure of an android project file in eclipse.
Then I went on to the next exercise using the Google MAP API. To get the key, I followed the instruction and now have a Google maps API key, this process was unfamiliar, I didn’t really understand what I was doing but it worked.
I was unable to get the exercise to work at first the code was showing up some errors, but I got it to work the following day, after doing the these tutorials
- http://developer.android.com/resources/tutorials/hello-world.html
- http://developer.android.com/resources/tutorials/views/hello-mapview.html
The problem I was having was with coordinates, I kept on getting a point in the ocean around Greenland, after restarting eclipse it worked, I spent about 2 hours on this but I now understand this part of the code much more. I added the following into the rave short courses code, to get a specific location. It took me a while to extract coordinates from Google maps as they hide them. Once I found the longitude and latitude, the values needed to be converted into Micro degrees, I used this mobiforge code to do the conversion.
Here is the code I added to get the location of the London 2012 site in Stratford
double lat = (51.537167);
double lng = (-0.01502);
GeoPoint point = new GeoPoint((int)(lat * 1e6), (int)(lng * 1e6));
mMapView.getController().animateTo(point);
To complete the exercise I needed to incorporate the following code, which I was unable to get to work.
@Override
public boolean onKey(View view, int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_N) {
mMapView.setSatellite(false);
}
if (keyCode == KeyEvent.KEYCODE_Y) {
mMapView.setSatellite(true);
}
if ((keyCode >= KeyEvent.KEYCODE_0) && (keyCode <= KeyEvent.KEYCODE_9)) {
mMapView.getController().setZoom(20 - keyCode + KeyEvent.KEYCODE_0);
}
return false;
}
Here is my Google maps app that shows the position of the London 2012 site in Stratford
As part of my project exploration I wanted to see how easy it was to add a RSS feed in to a web app, I found some example code and explanation –
- http://www.ibm.com/developerworks/opensource/library/x-android/index.html?ca=dgr-lnxw82Android-XML&S_TACT=105AGX59&S_CMP=grlnxw82
- http://www.warriorpoint.com/blog/2009/07/19/android-reading-using-and-working-with-xml-data-and-web-services-in-android/
I downloaded and imported the project in to eclipse and ran it, (managed to do this without any instructions, this shows my learning is progressing)
Then changed a few parameters:
- Changed the feedURL in feedPaserFactory
static String feedUrl = "http://www.london2012.com/news/news.rss";
- Changed the app name to London 2012 in strings.xml
<string name="app_name">London 2012</string>
- Also the text was quite crowded, so I increased the padding and spacing. I added this code in to row.xml
android:padding="15dp"
android:textSize="21sp"
- I also wanted to show only the 10 most recent news stories I have not figured this out yet
- I changed the icon, to do this I created a new png, named it icon2, placed it in the same folder as the current icon and then changed this line of code in AndroidManifest.xml
- There is a menu for changing feeds sources, I would like to make my own customised menu, I need to do a tutorial on this functionality first
- I want to change the roll over colour, need to find the setting