<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>Randamblings of Joe</title>
	<atom:link href="http://randamblings.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://randamblings.wordpress.com</link>
	<description>The everyday ramblings of a lazy student</description>
	<lastBuildDate>Mon, 03 Oct 2011 16:17:37 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='randamblings.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>Randamblings of Joe</title>
		<link>http://randamblings.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://randamblings.wordpress.com/osd.xml" title="Randamblings of Joe" />
	<atom:link rel='hub' href='http://randamblings.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Days 7 &#8211; 9: Trial and Error</title>
		<link>http://randamblings.wordpress.com/2010/04/14/days-7-9-trial-and-error/</link>
		<comments>http://randamblings.wordpress.com/2010/04/14/days-7-9-trial-and-error/#comments</comments>
		<pubDate>Wed, 14 Apr 2010 00:32:06 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lc8n]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=112</guid>
		<description><![CDATA[So, 2 days without an update. That&#8217;s not to say I haven&#8217;t been working on it, but I&#8217;ve been mostly just trying out various different methods of displaying the overlays on the camera view. Today&#8217;s Results Last time I posted, I had the locations overlaid, but only moving from the left of the screen to [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=112&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, 2 days without an update. That&#8217;s not to say I haven&#8217;t been working on it, but I&#8217;ve been mostly just trying out various different methods of displaying the overlays on the camera view.</p>
<p><strong>Today&#8217;s Results</strong></p>
<p>Last time I posted, I had the locations overlaid, but only moving from the left of the screen to the right. After day 7 I had it moving both left and right and up and down. I spent most of day 8 trying to get them to move slightly differently, but in the end decided that what I had in the first place was probably the best I would get. Today I played with the distance values, and now have the pointers resized and moving at varying speeds depending on how close you are.</p>
<p><a href="http://randamblings.files.wordpress.com/2010/04/day9-1.png"><img class="alignnone size-full wp-image-114" title="day9-1" src="http://randamblings.files.wordpress.com/2010/04/day9-1.png?w=780" alt=""   /></a></p>
<p>Again it&#8217;s hard to show it working properly without any locations visible, but the example here is showing various cinemas in a 10km area. The large one is my town&#8217;s cinema, the smallest ones are in other towns further away.</p>
<p>Then, if I rotate the phone to the right a bit:</p>
<p><a href="http://randamblings.files.wordpress.com/2010/04/day9-2.png"><img class="alignnone size-full wp-image-113" title="day9-2" src="http://randamblings.files.wordpress.com/2010/04/day9-2.png?w=780" alt=""   /></a></p>
<p>The nearby one has moved much further to the right than the distant ones. This is similar to the perspective of objects that you can see. For example, right now, I&#8217;m sitting in front of my computer, which is in front of a window. If I move to the left, I can&#8217;t see the monitor in front of me any more, but I can still see the next house out of the window.</p>
<p>The slider doesn&#8217;t do a lot at the moment. It&#8217;s supposed to affect the display area, but at the moment it only uses these values for the google search. While this does prioritise nearby locations, if there aren&#8217;t many locations that match in that area, it&#8217;ll still return some faraway things. I think rather than making this a fully adjustable scale, I&#8217;ll probably make 3-4 &#8216;levels&#8217; of search area. Right now the perspective/sizes change over quite a large distance, with the smallest size being at over 10km away. Obviously if you&#8217;re in a city and actually looking at buildings, you don&#8217;t care about things 10km away, and all of the things you&#8217;re looking at would be within 100m of you. Right now, those would all be shown at the same size. I&#8217;ve had to do this for testing because there aren&#8217;t any locations near me which I can search. I&#8217;m also not applying any specific calculations to work out the size. I&#8217;m using log on the distances and going from there, but then I&#8217;m just using a bunch of if statements to categorise each point into a specific size.</p>
<p>If I can work out a better way of calculating it I might make a full sliding scale. I also need to find a better way to filter the search results though, as right now it would still display faraway items if you set the area to the minimum, and these results were producing huge/inverse images because it was scaling them by a negative number from the calculations I tried. There are various ways around this, but for now the method I&#8217;ve got is working well.Currently I&#8217;m aiming to have, say a&#8221;city&#8221; view, where you just want things that you can see very close by, a &#8220;wide range&#8221; view, where you can see all of the results in the region, and 1 or 2 in between that. That should be sufficient for now.</p>
<p><strong>The Code/Maths</strong></p>
<p>I won&#8217;t go into all the details because it hurts my head now, but I&#8217;ll explain a few of the basics.</p>
<p>I said a few days ago that I didn&#8217;t think I&#8217;d have to worry about the Accelerometer values, but it turns out that I do. The orientation values basically show how far they are rotated away from a specific point, but not in positives and negatives. For example, if you&#8217;re holding it flat, it will say 0 degrees. You rotate it upwards slighly, it will say 10 degrees. But if you rotate it downwards slightly from flat, it will also show 10 degrees. The values also jump between 0, 180, and -180 at certain points, so it can be quite confusing. Enter the accelerometer. This sensor -does- know if it&#8217;s tilted upwards or downwards. The specific numbers it&#8217;s giving don&#8217;t mean much, but the key piece of information here is whether it&#8217;s positive or negative. As with the previous example, you have 10 degrees in both cases, but in one case the accelerometer value will be negative, and in the other, it will be positive. You can use this in a simple if statement to perform a different calculation depending on the accelerometer value.</p>
<p>After implementing the movement in two dimensions, I ran into another problem. It worked fine if I was holding it perfectly horizontal, but if it was rotated sideways, moving it up or down would result in the points jumping across the screen at certain points. The solution to this was using the third orientation value, and another accelerometer value. So basically, I have 4 sets of calculations for each combination of positive or negative on each of the accelerometer values. This then allows me to rotate the points to match the users view too, and overcomes the jumps across the screen.</p>
<p>As I&#8217;ve said, I&#8217;m not going to go into detail here, but I&#8217;ll give 3 suggestions:</p>
<p>Read this tutorial. I don&#8217;t think the maths is entirely correct, but it should give you an idea of how it works:</p>
<p>http://www.devx.com/wireless/Article/42482/1954</p>
<p>Download &#8220;SensorList&#8221; on your Android phone. This gives you the outputs for each of the sensors, and a graph of them. From this, you should be able to work out what you need to do with the numbers. Pay close attention to what happens to the numbers as you tilt it past horizontal or vertical on each axis.</p>
<p>Contact me via comments or email and I&#8217;ll try and explain it a bit better. I also plan on writing an in-depth tutorial once this is all finished.</p>
<p>The distance calculations again took some trial and error. Many attempts resulted in markers which were either far too big, far too small, or not enough differentiation between the distances. I overcame this by first finding the logarithm of the distances. Currently, I do want to see faraway points, but I don&#8217;t care about much beyond 10km away. In log base 10, 10000 is 4. Using a sort of semilogarithmic scale, I took these values, and as the log10 of the distance went up by 0.25, I increased the scale by 0.2, ranging from 2 to 4, which is between 100m and 10km. There are no results closer than 100m to me right now, and only a few within 500m or so, so this worked well for now. But when you&#8217;re in a city and just want to see what&#8217;s within 100m of you, this will have to be changed. The log10 of anything below 1 is a negative number, which would cause issues with the scale, but this isn&#8217;t a problem in this case because the GPS isn&#8217;t accurate enough to say that something is less than a meter away from you. But I&#8217;ll have to change the scale of this for using a smaller search area, such as between 1 (10 meters) and 2 (100 meters), possibly up to 3 (1km) for very small outliers.</p>
<p>Another issue I encountered was that the app was getting increasingly slow, to the point that it was very difficult to even type in search queries, and the points were not moving across the screen very smoothly. This was solved (partially) by looking into the garbage collector. If you look at LogCat in DDMS when you have an app running, you&#8217;ll see something along the lines of &#8220;GC cleared 1000 objects in 100ms&#8221;. What this means is that it&#8217;s periodically stopping for a short period to clear stuff out of the temporary memory. 100ms doesn&#8217;t seem like a lot, but it makes quite a difference with a real time application of this nature. Especially when it has to do this for every draw cycle. The reason that this happens is when you create objects in some way like Paint paint = <strong>new Paint(); </strong>it&#8217;s creating a whole new object which you&#8217;re not getting rid of. Java deals with this stuff on it&#8217;s own quite well, compared to languages like C where you have to do all of this yourself.</p>
<p>In my case, I was creating new Location objects for every search result (up to 8 at a time) on every draw cycle (which occur multiple times per second). The solution to this is to declare your objects as private at the start of the program, and set them up in your onCreate method. You can then simply edit and refer to them in your draw cycles, rather than creating endless objects multiple times per second. Mostly these sorts of problems can be solved by looking for any lines that are creating objects by using the <strong>new</strong> operator, particularly within your onDraw methods, and also sensor listener methods. The background APIs are going to do a fair bit of object creation on their own too, so you won&#8217;t be able to get rid of everything, but you&#8217;ll be able to avoid significant issues. There&#8217;s also the issue that declaring the object for the entire program will take up more memory in the long run, rather than only for a short time. Depending on the nature of your app you might not want to do something like this, but for graphics-heavy apps, it helps a lot.</p>
<p><strong>The Next Steps</strong></p>
<p>I have the foundations augmented reality working now. There are a few more steps to perfect it, though I&#8217;d like to move on to the bigger parts and come back to the minor details when there&#8217;s time.</p>
<ul>
<li>Showing details of the location on camera view. Currently there&#8217;s no way to see -what- locations you&#8217;re looking at, unlike on the map where you can click to see the name of it. I had trouble implementing any sort of click listener for the images, but there&#8217;s probably a way. Alternatively, an overlay could just display the details of the nearest point to the center.</li>
<li>Set up the different search areas to work correctly.</li>
<li>Sort the Google search results so that irrelevant results are discarded, and closest items are prioritised. Also need to search through multiple results beyond 8.</li>
<li>Test to make sure the results are accurate in a city area.</li>
</ul>
<p>That&#8217;s about it for the app itself. Beyond that, I need to create a database for adding my own points, so that it can be demonstrated at the University, and extended further in the future. This is fairly simple, and I&#8217;ll probably just do it by setting up a MySQL server on my website and a PHP script to create the JSON output. It would be easier to encode the JSON output in Java using the Jackson libraries, but then it&#8217;ll take more work to it up to receive HTTP requests. Javascript is another option but I&#8217;m not familar with it.</p>
<p><strong>Tomorrow&#8217;s Goal</strong></p>
<p>One more day working on the minor points described above. Location details are very important and I still need to decide on how to display it. Search areas are quite important but I&#8217;m pretty confident of how to do this. Google results are less important as I won&#8217;t need to be showing many Google results in my University demonstration, but it would be good to improve this.</p>
<p><strong>Links</strong></p>
<p>As I said, most of this was all trial and error til I got it right. I&#8217;ll point you to this tutorial again which helps with getting started in Augmented Reality, though the maths doesn&#8217;t appear to be entirely correct.</p>
<p>http://www.devx.com/wireless/Article/42482/1954</p>
<p>This page explains how to make your app more efficient by dealing with the Garbage Collector.</p>
<p>http://blog.javia.org/android-allocation-free-code-avoids-the-gc-freeze/</p>
<p>This app is very useful for working out what you need to do with your sensor outputs. It gives you every number your sensors are outputting, and plots them on a graph.</p>
<p>http://www.androlib.com/android.application.com-miian-android-sensors-xmiE.aspx</p>
<p>Alternatively, here&#8217;s the QR code link which you can scan on your Android phone, to take you directly to the market download.</p>
<p><img class="alignnone" title="SensorList QR Code" src="http://chart.apis.google.com/chart?cht=qr&amp;chs=135x135&amp;chl=market://search?q=pname:com.miian.android.sensors" alt="" width="135" height="135" /></p>
<p><img src="///tmp/moz-screenshot.png" alt="" /></p>
<div id="_mcePaste" style="overflow:hidden;position:absolute;left:-10000px;top:1258px;width:1px;height:1px;">http://www.devx.com/wireless/Article/42482/195</div>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/112/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/112/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/112/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=112&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/14/days-7-9-trial-and-error/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day9-1.png" medium="image">
			<media:title type="html">day9-1</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day9-2.png" medium="image">
			<media:title type="html">day9-2</media:title>
		</media:content>

		<media:content url="http://chart.apis.google.com/chart?cht=qr&#38;chs=135x135&#38;chl=market://search?q=pname:com.miian.android.sensors" medium="image">
			<media:title type="html">SensorList QR Code</media:title>
		</media:content>
	</item>
		<item>
		<title>Day 6: Camera Location Search and Custom Views</title>
		<link>http://randamblings.wordpress.com/2010/04/11/day-6-camera-location-search-and-custom-views/</link>
		<comments>http://randamblings.wordpress.com/2010/04/11/day-6-camera-location-search-and-custom-views/#comments</comments>
		<pubDate>Sun, 11 Apr 2010 01:20:34 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lc8n]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=103</guid>
		<description><![CDATA[Just a short post because it&#8217;s late. Today was a bit frustrating, mostly trying to do minor things, but the result feels like a fairly big breakthrough, and the app is now doing what it was originally intended to do, albeit in a very rough form. Today&#8217;s Results The main result today was that I [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=103&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a short post because it&#8217;s late. Today was a bit frustrating, mostly trying to do minor things, but the result feels like a fairly big breakthrough, and the app is now doing what it was originally intended to do, albeit in a very rough form.</p>
<p><strong>Today&#8217;s Results</strong></p>
<p>The main result today was that I can now search for locations and display them on the camera view. It&#8217;s really starting to come together now.</p>
<p>The only thing that remains for this part of the app is to do a bit more with these overlays so that they&#8217;ll line up correctly with buildings at different angles and distances. This is mostly just maths that is going to take some thinking about, but the basis of the application is mostly there now.</p>
<p>A few pictures for now:</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day6-2.png"><img title="day6-2" src="http://randamblings.files.wordpress.com/2010/04/day6-2.png?w=200&#038;h=300" alt="" width="200" height="300" /> </a><a href="http://randamblings.files.wordpress.com/2010/04/day6-1.png"><img class="alignnone size-medium wp-image-107" title="day6-1" src="http://randamblings.files.wordpress.com/2010/04/day6-1.png?w=300&#038;h=200" alt="" width="300" height="200" /></a> <a href="http://randamblings.files.wordpress.com/2010/04/day5-ui.png"><img class="alignnone size-medium wp-image-109" title="day5-ui" src="http://randamblings.files.wordpress.com/2010/04/day5-ui.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p style="text-align:left;">The first 2 are searching for the local Tesco&#8217;s, before I added search boxes there. Not particularly descriptive pictures considering I can&#8217;t actually see those locations from here. But, you can see that there are -some buildings- over there in the distance. And just for proof, here&#8217;s some map view shots to confirm.</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day6-m.png"><img class="alignnone size-medium wp-image-105" title="day6-m" src="http://randamblings.files.wordpress.com/2010/04/day6-m.png?w=200&#038;h=300" alt="" width="200" height="300" /></a> <a href="http://randamblings.files.wordpress.com/2010/04/day6-m2.png"><img class="alignnone size-medium wp-image-104" title="day6-m2" src="http://randamblings.files.wordpress.com/2010/04/day6-m2.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p style="text-align:left;">So you can see I am indeed facing Tesco, and you can just about tell that I&#8217;m standing in that place from the map -  you can see the power line going through the garden.</p>
<p style="text-align:left;">A lot of the day was spent screwing around with XML and views trying to get the search box on the camera view, and changing them to image buttons. I got it in the end though.</p>
<p style="text-align:left;">I&#8217;m pretty excited at the progress I&#8217;ve made, and how close it feels to the end now. I just need to do some maths-foo, and then this section is done. After that I plan on making my own server application for adding locations too, but that shouldn&#8217;t be too complex. Then I just need to make it so that it can be sent search queries, and output the result in the same JSON format that I&#8217;m already dealing with for Google.</p>
<p style="text-align:left;">I&#8217;ll post some code bits tomorrow, though there&#8217;s not too much to see beside the calculations for displaying the markers on the screen.</p>
<p style="text-align:left;"><strong>Tomorrow&#8217;s goal</strong></p>
<p style="text-align:left;">I&#8217;ll be going in to town to test it out some. I&#8217;d like to try and implement some of the maths to calculate the height, and varying positions depending on the distance, but I think that&#8217;s mostly going to be down to trial and error.</p>
<p style="text-align:left;"><strong>Links of the Day</strong></p>
<p style="text-align:left;">Only one really. Most of the day was just testing stuff, and combating the NullPointerExceptions that they resulted in</p>
<p style="text-align:left;">http://mylifewithandroid.blogspot.com/2008/04/custom-views.html<br />
Fairly simple explanation of how to make your own custom views and put them into the XML file.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/103/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/103/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/103/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=103&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/11/day-6-camera-location-search-and-custom-views/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day6-2.png?w=200" medium="image">
			<media:title type="html">day6-2</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day6-1.png?w=300" medium="image">
			<media:title type="html">day6-1</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day5-ui.png?w=200" medium="image">
			<media:title type="html">day5-ui</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day6-m.png?w=200" medium="image">
			<media:title type="html">day6-m</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day6-m2.png?w=200" medium="image">
			<media:title type="html">day6-m2</media:title>
		</media:content>
	</item>
		<item>
		<title>Day 5: CameraView and some Math</title>
		<link>http://randamblings.wordpress.com/2010/04/10/day-5-cameraview-and-some-math/</link>
		<comments>http://randamblings.wordpress.com/2010/04/10/day-5-cameraview-and-some-math/#comments</comments>
		<pubDate>Sat, 10 Apr 2010 01:53:06 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[technology]]></category>
		<category><![CDATA[apps]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lc8n]]></category>
		<category><![CDATA[mobile]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=86</guid>
		<description><![CDATA[As expected, today turned out to be a bunch of experimenting and not a lot of results. I have a general grasp of what I need to do now, but it looks like it may involve a bit of maths. Also, I&#8217;ve noticed that my blog is starting to pop up on Google search results [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=86&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>As expected, today turned out to be a bunch of experimenting and not a lot of results. I have a general grasp of what I need to do now, but it looks like it may involve a bit of maths.</p>
<p>Also, I&#8217;ve noticed that my blog is starting to pop up on Google search results for the sort of things I was searching for myself a few days ago. The code snippets I post here are probably a bit useless when they&#8217;re not seen in context with everything else, but then at this point I&#8217;m mostly posting them for myself to look back on later on. I plan on writing some tutorials once this is all finished, because there aren&#8217;t many out there, but for now, if you happen to come across this and you need some help trying to do similar things to what I&#8217;m doing, drop me an email at android@lc8n.co.uk</p>
<p><strong>Today&#8217;s Results</strong></p>
<p>Not a lot to show today, but I guess I do have something that could be classed, very very loosely, as an augmented reality application. I&#8217;ve moved onto another screen now, the Camera view. The intent is to take those Google search results I had on the maps yesterday, and have them being overlaid in the right place on the map.</p>
<p>I spent a long time playing around with overlay stuff, and trying to understand some maths, but in the end I tested it out, and I now have an overlay that shows you the location of the nearest compass point. That line probably doesn&#8217;t make much sense, so here&#8217;s some pictures :</p>
<p>(10 minutes later, after first posting the pictures I realised I&#8217;d done it wrong! Fixed now)</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day5-01.png"><img class="alignnone size-medium wp-image-92" title="day5-0" src="http://randamblings.files.wordpress.com/2010/04/day5-01.png?w=200&#038;h=300" alt="" width="200" height="300" /></a> <a href="http://randamblings.files.wordpress.com/2010/04/day5-12.png"><img class="alignnone size-medium wp-image-93" title="day5-1" src="http://randamblings.files.wordpress.com/2010/04/day5-12.png?w=200&#038;h=300" alt="" width="200" height="300" /></a> <a href="http://randamblings.files.wordpress.com/2010/04/day5-21.png"><img class="alignnone size-medium wp-image-94" title="day5-2" src="http://randamblings.files.wordpress.com/2010/04/day5-21.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p>It also works correctly in Landscape mode now:</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day5-l1.png"><img class="alignnone size-medium wp-image-95" title="day5-l" src="http://randamblings.files.wordpress.com/2010/04/day5-l1.png?w=300&#038;h=200" alt="" width="300" height="200" /></a></p>
<p style="text-align:left;">Also just to show that it is correct, here&#8217;s a comparison in the map view. I am indeed sitting in that location, facing west.</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day5-m1.png"><img class="alignnone size-medium wp-image-98" title="day5-m" src="http://randamblings.files.wordpress.com/2010/04/day5-m1.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p style="text-align:left;">Yes, I do need to fix those buttons.</p>
<p style="text-align:left;"><strong>The Code</strong></p>
<p style="text-align:left;">Of course, this is just dealing with changes in one dimension. When it comes to labelling buildings, I&#8217;m going to need to worry about 2 or 3 dimensions. The labels should move up or down depending on which way you&#8217;re pointing the camera, and it also needs to take into account the distance away it is, to get the perspective right. So that close things will move off of the screen if you move it a small distance, and far things stay on the screen across a larger range of movement. For example, on the middle screenshot above, if the &#8216;West&#8217; label was actually labelling my monitor, I wouldn&#8217;t want it on the left screenshot, because it&#8217;s off the screen. In the case of compass distance, we&#8217;re labelling something infinitely far away though.</p>
<blockquote>
<p style="text-align:left;">The code for working this out is pretty basic at the moment. I read some things about more complex calculations of the direction, but they didn&#8217;t seem to work, and right now, I&#8217;m able to do what I need to do through simpler means. As long as it works when I&#8217;m either holding it upright in portrait and landscape modes, that&#8217;s fine. Even just one of those would be ok for now, but it seems to be ok with both. I don&#8217;t need to worry about making it work when I&#8217;m upside down or laying on the floor. I also saw mention of using the accelerometer, but as of yet I don&#8217;t need to. Anyway, here&#8217;s an idea of the code for this bit -</p>
<p style="text-align:left;">if(dir&lt;45)<br />
{<br />
position = (canvas.getWidth()/2) &#8211; 50 &#8211; (dir *(canvas.getWidth()/90));<br />
canvas.drawText(&#8220;NORTH&#8221;, position, canvas.getHeight()/2, paint);<br />
}<br />
else if(dir&gt;45&amp;&amp;dir&lt;135)<br />
{<br />
dir = dir-45;<br />
position = canvas.getWidth() &#8211; 50 &#8211; (dir *(canvas.getWidth()/90));<br />
canvas.drawText(&#8220;EAST&#8221;, position, canvas.getHeight()/2, paint);<br />
}<br />
else if(dir&gt;135&amp;&amp;dir&lt;225)<br />
{<br />
dir = dir-135;<br />
position = canvas.getWidth() &#8211; 50 &#8211; (dir *(canvas.getWidth()/90));<br />
canvas.drawText(&#8220;SOUTH&#8221;, position, canvas.getHeight()/2, paint);<br />
}<br />
else if(dir&gt;225&amp;&amp;dir&lt;315)<br />
{<br />
dir = dir-225;<br />
position = canvas.getWidth() &#8211; 50 &#8211; (dir *(canvas.getWidth()/90));<br />
canvas.drawText(&#8220;WEST&#8221;, position, canvas.getHeight()/2, paint);<br />
}<br />
else<br />
{<br />
dir = dir-315;<br />
position = canvas.getWidth() &#8211; 50 &#8211; (dir *(canvas.getWidth()/90));<br />
canvas.drawText(&#8220;NORTH&#8221;, position, canvas.getHeight()/2, paint);<br />
}</p>
</blockquote>
<p style="text-align:left;">Looks a bit long winded, but it&#8217;s pretty simple. Basically, it&#8217;s printing a different string depending on which quarter of the degree range you&#8217;re facing. it&#8217;s split into 5 because north is from 0-45 degrees and 315 to 0 degrees. In each case, it converts the degrees into a relative position between the two nearest compass points, and then converts that into a position on the screen. Wow, that didn&#8217;t make much sense. I&#8217;m sure I could do it in a much simpler way, but this was just a basic test for the moment.</p>
<p style="text-align:left;">I also had a look into the Google search results from yesterday in a bit more detail. There were two issues that came about yesterday. For one, it was showing things that weren&#8217;t at all relevant sometimes (pubs when I searched for train stations), and sometimes it wasn&#8217;t showing the most relevant things either.</p>
<p style="text-align:left;">The first issue is fairly easy to filter out. There&#8217;s also an &#8216;accuracy&#8217; value for each search result. The actual train stations had an accuracy of 1, while the pub had an accuracy of 8. So, obviously the lower accuracy value the better. Turns out that the pub actually does have a review that mentions that it&#8217;s easy to get to from the train station, which is why it showed up, but fortunately Google has taken care of this issue by calculating this accuracy score.</p>
<p style="text-align:left;">I also realised that it was only returning 4 search results. To see more you need to specify a &#8220;start&#8221; value. I&#8217;d like to be able to do this without having to send countless search requests, but I&#8217;m not sure how easy that would be. Ideally I&#8217;d like to be able to sort them by accuracy, and return the top x number of results, or everything with an accuracy below a certain number. Unfortunately Google doesn&#8217;t seem to provide the functionality to sort local search results in any other way. You can choose to sort news and blog posts by relevance or date, but it would be nice to see the option to sort local results either by distance or relevance. I guess that could throw up some other issues too though.</p>
<p style="text-align:left;">Another handy feature is that you can provide it with an area to search. Previously I was just giving it a center point, so it was giving things that were quite a way away sometimes. But again, thanks to the magic of google&#8217;s API, you can get the degrees that are covered by your current view, so you can provide these to the search easily. That way, you&#8217;re only getting search results that you can actually see right now. In the context of the camera view, you&#8217;d probably want to limit it to locations that are pretty close to you, and this could maybe be controllable by the user to say how far away they want to show. I&#8217;ll need to work out how to get these sort of numbers into the correct format.</p>
<blockquote>
<p style="text-align:left;">double lat = p.getLatitudeE6()/1E6;<br />
double lng = p.getLongitudeE6()/1E6;<br />
double latspan = mapView.getLatitudeSpan()/1E6;<br />
double lngspan = mapView.getLongitudeSpan()/1E6;<br />
results = gs.runJSONParser(URLEncoder.encode(edit.getText().toString()),lat,lng,latspan,lngspan);</p>
</blockquote>
<p style="text-align:left;">And the code in the search class to run the search -</p>
<blockquote>
<p style="text-align:left;">Reader r = new InputStreamReader(getJSONData(&#8220;http://ajax.googleapis.com/ajax/services/search/local?v=1.0&amp;q=&#8221;+request+&#8221;&amp;sll=&#8221;+lat+&#8221;,&#8221;+lng+&#8221;&amp;sspn=&#8221;+latspan+&#8221;,&#8221;+lngspan&#8221;&amp;rsz=large&#8221;));</p>
</blockquote>
<p style="text-align:left;">So, first we&#8217;re giving it our search query, then our location. After that, the sspn parameter gives our search area. The rsz parameter of large specifies that we want 8 results. Unfortunately you can only choose between 4 (small) or 8 (large) here. You can then supply &amp;start=9 after that, and so on, to get more results. There is also a field in the JSON response that shows how many results there are, so you know how far to look.</p>
<p style="text-align:left;"><strong>Tomorrow&#8217;s Goal</strong></p>
<p style="text-align:left;">Hopefully make some progress on overlaying the locations on the screen. I doubt I can get it perfect tomorrow, but hopefully something that generally works. I won&#8217;t be able to test this too well tomorrow at home, but I&#8217;m going into town on Sunday, so I&#8217;ll be able to see if it&#8217;s working then.</p>
<p style="text-align:left;"><strong>Links of the Day</strong></p>
<p style="text-align:left;">http://www.devx.com/wireless/Article/42482/1954<br />
This article basically gives you a crash course in starting up an AR application. A lot of it covers the same stuff as my previous posts, but it&#8217;s mostly concise and simple. It only covers the backend stuff though, rather than any output.</p>
<p style="text-align:left;">http://www.devx.com/wireless/Article/43005/<br />
The second part of the above article. As I said, the maths here doesn&#8217;t seem to work for me, but so far I haven&#8217;t needed it. That may change tomorrow.</p>
<p style="text-align:left;">http://code.google.com/apis/ajaxsearch/documentation/reference.html#_intro_fonje<br />
A detailed list of the parameters you can provide in each sort of Google search</p>
<p style="text-align:left;">http://www.mail-archive.com/android-developers@googlegroups.com/msg22032.html<br />
A pretty simple example of showing Overlays on the camera view. Probably irrelevant for most people, unless like me, you jumped into making an AR app without any experience of Android development!</p>
<p style="text-align:left;">If you have any questions or comments about anything here, feel free to contact me, either via the comments on here, or email at android@lc8n.co.uk</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/86/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/86/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/86/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=86&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/10/day-5-cameraview-and-some-math/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day5-01.png?w=200" medium="image">
			<media:title type="html">day5-0</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day5-12.png?w=200" medium="image">
			<media:title type="html">day5-1</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day5-21.png?w=200" medium="image">
			<media:title type="html">day5-2</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day5-l1.png?w=300" medium="image">
			<media:title type="html">day5-l</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day5-m1.png?w=200" medium="image">
			<media:title type="html">day5-m</media:title>
		</media:content>
	</item>
		<item>
		<title>Day 4: JSON and Google Local Search</title>
		<link>http://randamblings.wordpress.com/2010/04/08/day-4-json-and-google-local-search/</link>
		<comments>http://randamblings.wordpress.com/2010/04/08/day-4-json-and-google-local-search/#comments</comments>
		<pubDate>Thu, 08 Apr 2010 23:18:35 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lc8n]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=77</guid>
		<description><![CDATA[I posted yesterday that it looked like getting location information from Google would be pretty complicated. It took a while to work out what I needed to do, but in the end it wasn&#8217;t too bad. Today&#8217;s Results I met my goal again for today &#8211; I can search for specific locations, and they&#8217;re labelled [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=77&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I posted yesterday that it looked like getting location information from Google would be pretty complicated. It took a while to work out what I needed to do, but in the end it wasn&#8217;t too bad.</p>
<p><strong>Today&#8217;s Results</strong></p>
<p>I met my goal again for today &#8211; I can search for specific locations, and they&#8217;re labelled on the map.</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day4-1.png"><img class="size-medium wp-image-78 aligncenter" title="day4-1" src="http://randamblings.files.wordpress.com/2010/04/day4-1.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p>The items on the far left and right are indeed the nearest train stations. The one in the middle is actually a local pub &#8211; I&#8217;m not really sure why this result came up. For the most part this works really well though. It&#8217;s a bit laggy on loading the results, I need to come up with some sort of &#8220;Please wait, loading&#8221; popup, because currently it just hangs for a few seconds. In some cases it freezes when I search, and I&#8217;m not sure why, it seems fairly random. But generally, it works. If you tap one of the markers, currently it gives you a popup with information about the location</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day4-2.png"><img class="size-medium wp-image-79 aligncenter" title="day4-2" src="http://randamblings.files.wordpress.com/2010/04/day4-2.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p>Compared again to Google maps to show accuracy -</p>
<p style="text-align:center;"><a href="http://randamblings.files.wordpress.com/2010/04/day4-gmaps.png"><img class="alignnone size-medium wp-image-80" title="day4-gmaps" src="http://randamblings.files.wordpress.com/2010/04/day4-gmaps.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p style="text-align:left;">Obviously I could do with making my markers smaller, and ideally tapping on a location would bring up another overlay, or take you to another screen. It&#8217;s just for testing purposes right now though.</p>
<p style="text-align:left;"><strong>The Code</strong></p>
<p style="text-align:left;">Strangely, Google saw fit to not include any Google search functionality in their API. Presumably this is so people can&#8217;t steal their results and use them without branding, or something to that effect. I don&#8217;t really see how this is any different to being able to access it through your own web site though. But, there&#8217;s still a way to do it. I thought this would involve coding my own search script in javascript or some such, but it turns out they&#8217;ve done that much for us.</p>
<p style="text-align:left;">If you take this link &#8211; http://ajax.googleapis.com/ajax/services/search/web?v=1.0&amp;q=banana &#8211; it does a google search for &#8216;banana&#8217; and outputs the results in a format known as JSON. Somewhat similar in principle to XML, it&#8217;s basically a standard way of outputting sets of data, each of which has a type and a value. Normally if you want to take data from a text file and turn it into something you can manipulate in a program, you need to go through the long and boring task of writing methods to read a file, split it up, and work out what each section means.</p>
<p style="text-align:left;">Enter Jackson. Jackson is a fantastic library which does all the hard work for you. All you have to do is give it the JSON text, set up some classes which match the the data that&#8217;s included in it, and set it to work. Android does actually have it&#8217;s own JSON parser built in, but it&#8217;s not as simple to use, and apparently not as efficient. Jackson works just fine with Android though, so it&#8217;s easy to implement in your apps. There&#8217;s a basic tutorial over at the Jackson website (I&#8217;ll post it at the end of the post) which covers the basics, and it&#8217;s pretty simple. Firstly, you need to set up a class that will hold all the data from the JSON output. For example, if you had an output that had a list of people&#8217;s details, you&#8217;d want a Person class. In this class you just need to have parameter declarations which match the names of each item in the list, and getters and setters for each parameter. Google&#8217;s one outputs a bunch of stuff that you don&#8217;t really need, but you can just tell it to ignore anything you don&#8217;t define.</p>
<blockquote>
<p style="text-align:left;">private double lat;</p>
<p style="text-align:left;">public double getLat() {<br />
return lat;}<br />
public void setLat(double lat) {<br />
this.lat = lat;}</p>
</blockquote>
<p>To get the results from the internet you need to set up an InputStream  with a HttpClient</p>
<blockquote><p>public InputStream getJSONData(String url){</p>
<p>DefaultHttpClient httpClient = new DefaultHttpClient();<br />
URI uri;<br />
InputStream data = null;<br />
try{<br />
uri = new URI(url);<br />
HttpGet method = new HttpGet(uri);<br />
HttpResponse response = httpClient.execute(method);<br />
data = response.getEntity().getContent();<br />
}<br />
catch(Exception e)<br />
{<br />
e.printStackTrace();<br />
}</p>
<p>return data;</p>
<p>}</p></blockquote>
<p>The code to turn the data into Java objects is so simple it hurts, assuming you have your classes set up correctly.</p>
<p>Reader r = new InputStreamReader(getJSONData(&#8220;http://ajax.googleapis.com/ajax/services/search/local?v=1.0&amp;q=&#8221;+request+&#8221;&amp;sll=&#8221;+lat+&#8221;,&#8221;+lng));<br />
ObjectMapper mapper = new ObjectMapper();</p>
<p>mapper.configure(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);<br />
ResponseData responseData = mapper.readValue(r, ResponseData.class);</p>
<p>Results result = responseData.getResponseData();<br />
results = result.getResults();</p>
<p>Thanks to the long result strings Google gives, it took 3 classes for me to get it to read it correctly. The ResponseData class just has a single Results item in it, and this then contains a list of Result items. There might be a simpler way to do it, but I was getting all sorts of errors any other way I did it. I set it to ignore &#8216;unknown properties&#8217; (that is, anything that I haven&#8217;t defined in my classes) for 2 reasons &#8211; one, I don&#8217;t need all the data it gives you, two, it just failed to read one of the parameters (GsearchResultClass) no matter what I did. I&#8217;m not sure why, possibly to do with the capitalisation, but either way, I decided to just skip it.</p>
<p>If it all goes correctly. it should give you a list of result objects, which you can then use the getters you defined to get all your data out of it. Simple. The search URL for the Local search is a bit different -</p>
<p>http://ajax.googleapis.com/ajax/services/search/local?v=1.0&amp;q=PLACE TO SEARCH FOR&amp;sll=CO-ORDINATES TO SEARCH NEAR</p>
<p>for example</p>
<p>http://ajax.googleapis.com/ajax/services/search/local?v=1.0&#038;q=train&#038;sll=50.00001,-5.00001</p>
<p>Next I added a search box to my map screen, and set it to search when you hit the OK button</p>
<blockquote><p>button.setOnClickListener(new View.OnClickListener() {</p>
<p>public void onClick(View v) {<br />
double lat = p.getLatitudeE6()/1E6;<br />
double lng = p.getLongitudeE6()/1E6;<br />
results = gs.runJSONParser(URLEncoder.encode(edit.getText().toString()),lat,lng);<br />
OverlayItem oi;<br />
GeoPoint gp;<br />
int lati;<br />
int lngi;<br />
itemizedoverlay.clearOverlays();<br />
for(Result rs : results)<br />
{<br />
lati = (int)(rs.getLat()*1E6);<br />
lngi = (int)(rs.getLng()*1E6);</p>
<p>gp = new GeoPoint(lati,lngi);<br />
oi = new OverlayItem(gp,rs.getTitleNoFormatting(),rs.getStreetAddress());<br />
itemizedoverlay.addOverlay(oi);<br />
}<br />
}</p></blockquote>
<p>Here, we&#8217;re getting our current location, and the string in the search box, and passing it to our search function. Note that you need to convert the search string to a URI. This is the format of a web address, but essentially what this does here is convert any characters that a HTTP query can&#8217;t handle and convert them into something it can &#8211; for example converting a space into %20.</p>
<p><strong>The Next Step:</strong></p>
<p>I&#8217;m pretty much done with the back end stuff now, and I&#8217;ve got all the data I need. There are two other parts to the project -</p>
<ul>
<li>Create a custom database so I can add my own locations to it</li>
<li>Turn it all into an augmented reality application</li>
</ul>
<p>For those unfamiliar with the term augmented reality &#8211; it&#8217;s all the rage these days, applications that take your camera view, and overlay things on top of that. The idea of this app is that I&#8217;ll take this location information from Google, and overlay that on the camera, roughly at the location of the buildings.</p>
<p>I&#8217;m not really sure where to start with this, so it&#8217;ll be interesting. Over the last few days, I&#8217;ve been able to read up on the basics on various tutorials. Today I was getting to the point where there just wasn&#8217;t any information out there. There are obviously applications out there that do use Google search functionality, but most aren&#8217;t willing to share their experience. Along with that, Google doesn&#8217;t like people accessing search results directly via Android, so there&#8217;s no documentation for it.</p>
<p><strong>Tomorrow&#8217;s Goal</strong></p>
<p>Hard to say anything specific. I&#8217;ll have a look at setting up a Camera view and see what I can do with it.</p>
<p><strong>Links of the Day</strong></p>
<p>http://www.softwarepassion.com/android-series-parsing-json-data-with-gson/</p>
<p>This refers to using the GSON library for JSON parsing, which works similarly to Jackson, but is apparently slower.</p>
<p>http://wiki.fasterxml.com/JacksonInFiveMinutes</p>
<p>Jackson&#8217;s basic tutorial. Explains the basics very well.</p>
<p>http://code.google.com/apis/ajaxsearch/documentation/#fonje</p>
<p>Explains how to use Google&#8217;s search API and some basics of how to call it in Java.</p>
<p>As usual, feel free to leave a comment or email android@lc8n.co.uk if you need any further information. Interestingly this blog has had 40 hits today, and I&#8217;m not sure where from. I&#8217;ve been tagging it here and on twitter, but I have all of 5 followers on Twitter (ProbablyJoe if you feel so inclined) and I&#8217;ve given this link to about 5 people. Interesting.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/77/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/77/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/77/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=77&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/08/day-4-json-and-google-local-search/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day4-1.png?w=200" medium="image">
			<media:title type="html">day4-1</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day4-2.png?w=200" medium="image">
			<media:title type="html">day4-2</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day4-gmaps.png?w=200" medium="image">
			<media:title type="html">day4-gmaps</media:title>
		</media:content>
	</item>
		<item>
		<title>Day 3: Overlays and Geocoding (Pt 2)</title>
		<link>http://randamblings.wordpress.com/2010/04/07/day-3-overlays-and-geocoding-pt-2/</link>
		<comments>http://randamblings.wordpress.com/2010/04/07/day-3-overlays-and-geocoding-pt-2/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 23:07:13 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lc8n]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=70</guid>
		<description><![CDATA[Right, so I didn&#8217;t get to see the movie because it was all sold out, but I did get to take my phone for a stroll around town to see if it knew where I was. It did. Mostly. Today&#8217;s Results As I said in the previous post, the built in address location stuff is [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=70&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Right, so I didn&#8217;t get to see the movie because it was all sold out, but I did get to take my phone for a stroll around town to see if it knew where I was. It did.</p>
<p>Mostly.</p>
<p><strong>Today&#8217;s Results</strong></p>
<p>As I said in the previous post, the built in address location stuff is very simple, but not as accurate as I&#8217;d like. Here&#8217;s what I get for my house (I worked out how to screenshot my phone!)</p>
<p><a href="http://randamblings.files.wordpress.com/2010/04/day3.png"><img class="alignnone size-medium wp-image-71" title="day3" src="http://randamblings.files.wordpress.com/2010/04/day3.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p>First thing to note: No, my house is not so huge that it takes up 40 street numbers. It does in fact just have one number in that range. Unfortunately, the &#8216;reverse geocoding&#8217; method is only able to give you this level of accuracy.</p>
<p>As yesterday, the pointer isn&#8217;t entirely accurate, but I&#8217;m inside and it&#8217;s still very close (about 10 meters off)</p>
<p>The direction pointer is using the built in compass. This is only correct if you&#8217;re holding it in portrait mode and the correct way up. I need to work out how to change this for landscape mode.</p>
<p>The first two &#8216;issues&#8217; there are not specific to my application though. If I show the same screen in the built in Google Maps application:</p>
<p><a href="http://randamblings.files.wordpress.com/2010/04/gmaps.png"><img class="alignnone size-medium wp-image-72" title="gmaps" src="http://randamblings.files.wordpress.com/2010/04/gmaps.png?w=200&#038;h=300" alt="" width="200" height="300" /></a></p>
<p>One issue I did run into is that it was -extremely- laggy, to the point where I had to kill it and reload it every few minutes. I think this is just down to the fact that I&#8217;m making it create a pop up message every time the location changes. Ideally I&#8217;d put this in another overlay, I just put it in a popup for testing, because the Toast function is nice and simple to use. Yes, Android&#8217;s popup class is called Toast. I know when I was doing this for showing the compass direction (which changes even more often) it crashed in a matter of seconds, so it should be fine if I remove that.</p>
<p><strong>The Code:<br />
</strong></p>
<p>The first thing was getting the orientation. This is actually really simple, though the issue was displaying it. Similarly to getting the location, you create a sensor listener, and you tell it what to do whenever the values from a specified sensor (the compass, in this case) change. This is where it became a bit confusing &#8211; I thought I wanted to rotate the marker when this happened, but actually this wasn&#8217;t the case. All I wanted to do was get the value, and then use them when I drew the marker. It sounds pretty much the same, but it works out quite differently.</p>
<p>I spent a lot of time finding a different way to show my marker on the screen. Android has plenty of built in ways of doing this for you, either by using a MapOverlay, which binds a marker to specific co-ordinates, or the built in MyLocationOverlay, which does all the work for you and puts a marker right where you are. However, since I want to display the direction we&#8217;re facing, I need to be able to rotate this marker. There&#8217;s no built in method for this with the MapOverlays, and in fact you can&#8217;t rotate a &#8216;drawable&#8217; &#8211; that is, an image that&#8217;s stored within the program, at all. Firstly, you need to change it to a bitmap, then use a matrix to rotate it. We also need to know where on the screen to put it. Currently we just know where in the world we want it to point to. Good news is, there&#8217;s a simple method to convert that to a pixel co-ordinate on the screen too. Here&#8217;s all the code to do it.</p>
<blockquote><p>Paint paint = new Paint();<br />
Point pt  = new Point();<br />
mapView.getProjection().toPixels(p, pt);</p>
<p>Bitmap bmp = BitmapFactory.decodeResource(getResources(),R.drawable.pointer);</p>
<p>Matrix matrix = new Matrix();<br />
matrix.postTranslate(-25, -25);<br />
matrix.postRotate(ori);<br />
matrix.postTranslate(pt.x, pt.y);<br />
paint.setAntiAlias(true);<br />
paint.setFilterBitmap(true);</p>
<p>canvas.drawBitmap(bmp, matrix, paint);</p></blockquote>
<p>First of all we&#8217;re getting our pixel location, then we&#8217;re converting our image to a bitmap. The first matrix translation is essentially centering the image, so it&#8217;s rotated around this point. If you don&#8217;t do this, it rotates around the top left corner, which is no good. Then we&#8217;re rotating it by the orientation &#8211; this is obtained from another section which gets the value from the sensor. Fortunately they&#8217;re both float values of degrees, so they go together just fine. Then we move the rotated image to our location. We anti-alias and filter the image to make it look nice, then we draw it using these settings.</p>
<p>A lot of coding in Android revolves around telling it what to do when events occur. These events generally have functions already coded in, so what we have to do is override those functions and tell it what we want to do when it occurs. In the above case, we&#8217;re overriding the draw function, which is refreshed pretty often.</p>
<p>@Override<br />
public void draw(Canvas canvas, MapView mapView, boolean shadow)</p>
<p>The next step was to get my location. I thought this would be quite complex, but Android has another nice built in method known as the Geocoder. What this does is take in latitudes and longitudes, checks some magical database somewhere, and spits out an address. We already have the latitudes and longitudes from our GPS, so that&#8217;s nice and simple.</p>
<p>List&lt;Address&gt; address = gc.getFromLocation(loc.getLatitude(), loc.getLongitude(), 5);<br />
Address add1 = address.get(0);</p>
<p>It returns a list of addresses, but in practice I&#8217;m not sure why. Everything after the first result just seemed to only show one particular item, such as the city or county. But anyway, we get the first one, and from that we can get strings of each particular thing we want. It&#8217;s as simple as add1.getPostalCode() for the post code, and so on.</p>
<p><strong>The Next Step:</strong></p>
<p>Unfortunately, this isn&#8217;t as accurate as I&#8217;d like it to be, and I really need specific information about individual buildings, such as those that Google Maps provides on the internet. Unfortunately, Google doesn&#8217;t let you have this feature directly in the Android APIs, presumably because they don&#8217;t want people making free satnavs. There is another way though. Fortunately Google has a bunch of APIs for searching, and they return results in a format called JSON. This uses JavaScript, which I&#8217;ve never really looked at, but the end result is that it gives you an output with all the information you need. It&#8217;s a similar sort of format to XML but supposedly easier for programs to read.</p>
<p>So in this case, I won&#8217;t be getting the information from the built in functions, but requesting it from a web site. From there, it should be fairly simple to put the information on the map.</p>
<p><strong>Tomorrow&#8217;s Goal</strong></p>
<p>Be able to search for specific locations via Google, and overlay them on the map.</p>
<p><strong>Links of the Day</strong></p>
<p>http://www.androidcompetencycenter.com/tag/map-overlay/</p>
<p>A useful tutorial on creating overlays on maps</p>
<p>http://www.developer.com/java/j2me/article.php/3748281/Working-with-Images-in-Googles-Android.htm</p>
<p>Misc information about how Android handles images</p>
<p>http://blogoscoped.com/archive/2008-12-15-n14.html</p>
<p>I posted this yesterday too for the location stuff, but it also has a section about Geocoding.</p>
<p>Note that anything you find about the googlenav class is no good now. Google removed this functionality a few versions ago.</p>
<p>http://www.anddev.org/resize_and_rotate_image_-_example-t621.html</p>
<p>The correct way to rotate and resize images! (rotating the canvas is not correct)</p>
<p>If you have any questions</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/70/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/70/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/70/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=70&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/07/day-3-overlays-and-geocoding-pt-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day3.png?w=200" medium="image">
			<media:title type="html">day3</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/gmaps.png?w=200" medium="image">
			<media:title type="html">gmaps</media:title>
		</media:content>
	</item>
		<item>
		<title>Day 3: Overlays and Geocoding (Pt 1)</title>
		<link>http://randamblings.wordpress.com/2010/04/07/day-3-overlays-and-geocoding-pt-1/</link>
		<comments>http://randamblings.wordpress.com/2010/04/07/day-3-overlays-and-geocoding-pt-1/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 18:48:52 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[google]]></category>
		<category><![CDATA[lc8n]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=67</guid>
		<description><![CDATA[Just a quick update, I&#8217;m about to go out and test my app on the open road! Also go and see Clash of the Titans, but it seems like a good opportunity to test it on a location besides my own house. Today has again been pretty productive, and I&#8217;ve managed to meet my own [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=67&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Just a quick update, I&#8217;m about to go out and test my app on the open road! Also go and see Clash of the Titans, but it seems like a good opportunity to test it on a location besides my own house.</p>
<p>Today has again been pretty productive, and I&#8217;ve managed to meet my own goals. The location pointer now rotates with your compass direction, and there&#8217;s also a small display of your current location.</p>
<p>The first half of the day was spent going in circles, trying to get the marker into a format that I could rotate. Once I had that all worked out correctly, it was fairly simple to add that in, as the hardware gives you your degree of rotation, and this can be directly applied to an image.</p>
<p>Location information was also easier than I expected, at least to a point. It seems like you don&#8217;t have full access to all the information that you&#8217;ll see on google maps itself, though it is -extremely- easy to take a co-ordinate, and get an address from it.</p>
<p>Now to see what it gives in some other places.</p>
<p>No pictures as of yet since it doesn&#8217;t seem to work with the emulator, but I&#8217;m planning on taking a camera with me to take pictures of the phone in action.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/67/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/67/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/67/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=67&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/07/day-3-overlays-and-geocoding-pt-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>
	</item>
		<item>
		<title>Day 2: MapViews and Locations</title>
		<link>http://randamblings.wordpress.com/2010/04/06/day-2-mapviews-and-locations/</link>
		<comments>http://randamblings.wordpress.com/2010/04/06/day-2-mapviews-and-locations/#comments</comments>
		<pubDate>Tue, 06 Apr 2010 23:01:49 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[lc8n]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=62</guid>
		<description><![CDATA[Today I took my first steps in creating the application. I was able to create a Map view which got your current location, and updated it in real time by displaying a marker on the map.<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=62&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>After yesterdays post, I dived headfirst into Android, with my only experience being a few hours doing basic examples, 6 months ago.</p>
<p>Needless to say, it took a while to get used to it again. Android is Java based, but also uses some XML for layouts. It takes some getting used to, but fortunately the API is pretty well documented. I spent a while not having a clue how to do anything, but after a while I caught up again.</p>
<p>Android is updated pretty often. I got my phone 6 months ago, and it was on version 1.5. The newest phones are being released with version 2.1, and there&#8217;s been 3 other versions in between. This is great because it means Google is adding new stuff all the time, but it&#8217;s also confusing because they&#8217;re also changing old stuff. Consequently, half the tutorials I&#8217;ve read are actually outdated, so it&#8217;s been difficult trying to work out why things aren&#8217;t working.</p>
<p>Anyway, by the end of yesterday I&#8217;d worked through a few tutorials and had a general idea of how to use Android again. Today I wanted to make some progress with the Google Maps API, and hopefully get it showing my location, and updating in real time.</p>
<p>Android applications work by displaying &#8216;Views&#8217;. These are basically layouts that are created with an XML file. Although, since I&#8217;m working with the Map view today, there&#8217;s not really any layout work to be done, and I just want a screen full of map. Some controls such as zoom are handy too, and fortunately these are built into the MapView class.</p>
<p>Displaying a map is pretty simple. You have to get an API key from Google to be allowed to access their maps,  and then it&#8217;s as simple as a few lines of code:</p>
<blockquote><p>mapView = (MapView) findViewById(R.id.mapview);<br />
mapView.setBuiltInZoomControls(true);<br />
mapView.setSatellite(true);</p></blockquote>
<p>The first line refers to the XML file, which supplies your API key, the second line says you want zoom buttons, and the third line says that you want satellite images. Removing this line would result in displaying plain road maps.</p>
<p>The result of this is a big world map which you can zoom in on. Not especially useful, but quite a lot for so little code. Thanks Google APIs.</p>
<p>The next step was to get my current location, and show it on the map. I ran into a few problems here, mainly because I was testing my application on the emulator. If you want your location data, you need GPS. Computers do not (generally) have GPS. Phones do. So if you&#8217;re testing it on your computer, you need to give it some fake GPS data. I read (incorrectly) somewhere that the emulator just supplied some fake GPS data automatically. Whether this was an old feature that removed, or this person was just wrong, I&#8217;m not sure. Eventually though, I found the DDMS screen in Eclipse, which gives you debugging information, and lets you supply data to the emulator. You can give it location data, phone calls, or even whole strings of locations for it to run through in a path.</p>
<p>Thanks to a combination of Google Maps (the internet version) supplying me with some strange numbers, and me getting my  latitudes and longitudes mixed up, I went from Ethiopia to Sweden to the middle of the Irish sea, and eventually got it to locate my house.</p>
<p>After a while of being confused, this turned out to be fairly simple too. Firstly you need to set up a LocationManager, which deals with getting your location information from some sort of &#8216;provider&#8217;.</p>
<blockquote><p>lm = (LocationManager)getSystemService(Context.LOCATION_SERVICE);</p></blockquote>
<p>Firstly you need to tell it where to get the data from. You can do this by setting certain &#8216;criteria&#8217; for the location data.</p>
<blockquote><p>Criteria criteria = new Criteria();<br />
criteria.setAccuracy(Criteria.ACCURACY_FINE);<br />
criteria.setAltitudeRequired(true);<br />
criteria.setBearingRequired(true);<br />
String provider = lm.getBestProvider(criteria, true);</p></blockquote>
<p>This is saying we want &#8216;fine&#8217; accuracy, we do want to know our altitude, and we do want to know our bearing (compass direction) in fact, those last two points are unnecessary right now, since I just want to know my location, but later on I will be needing that data. In fact, this whole section is fairly unnecessary right now, because I know I want to be dealing with the GPS. Alternatively you could use the mobile network to get your location &#8211; it&#8217;s less accurate but uses less power. There are also ways to combine the two for more accuracy. But in the end, the getBestProvider function just gives you a string which points you towards the provider. I could just supply &#8220;gps&#8221; manually here</p>
<blockquote><p>lm.requestLocationUpdates(provider, 10000, 0, ll);</p></blockquote>
<p>This tells the phone that we want our location to be updated regularly. provider is the string we got before, in this case &#8220;gps&#8221;, 10000 is the milliseconds between updates (initially I just set this to 0, and it basically crashed my phone because it was updating too much. In this case it&#8217;s 10 seconds, though it&#8217;s not entirely accurate. I&#8217;ll probably want it lower later on). The third argument allows us to say we only want to be updated when the location changes by x number of meters. With the nature of my application, I want to know whenever the location changes, so this is set to 0. The final argument is a LocationListener, which is an interface we need to add, which defines actions to be carried out on some location-specific events. The important thing here is that we want things to change on the screen whenever our location changes.</p>
<blockquote><p>private class MyLocationListener implements LocationListener<br />
{</p>
<p>public void onLocationChanged(Location loc) {<br />
if (loc != null) {<br />
mapView.invalidate();</p>
<p>int lat = (int)(loc.getLatitude()*1E6);<br />
int lon = (int)(loc.getLongitude()*1E6);<br />
float bear = loc.getBearing();</p>
<p>GeoPoint p = new GeoPoint(lat,lon);<br />
mc.animateTo(p);<br />
mc.setZoom(21);<br />
OverlayItem currentLocation = new OverlayItem(p,&#8221;You are here&#8221;,&#8221;Hi there&#8221;);</p>
<p>itemizedoverlay.addOverlay(currentLocation);</p>
<p>}<br />
}</p></blockquote>
<p>What&#8217;s happening here is that whenever the location changes, it resets the map, moves to the location, zooms in, and places a marker there. For some reason the GeoPoint object uses &#8216;microdegrees&#8217; while general latitude and longitude measurements are in degrees with many decimal points. So it&#8217;s being multiplied by 1E6 (10^6 or 1000000) to get it into the correct format.</p>
<p>I had a few issues with trying to get it to just move the marker rather than make a new one every time it updated, but I got there in the end. Next step is to get it showing the direction correctly (hence the .getBearing() function in there).</p>
<p>I then gave it a whirl on my phone, and it was working well. It pinpointed my location pretty accurately, which is good to know. I don&#8217;t have a camera to hand to show it working on my phone, but I can show some screenshots of the emulator.</p>
<p><a href="http://randamblings.files.wordpress.com/2010/04/day2.png"><img class="alignnone size-medium wp-image-63" title="Day 2: MapView and Location" src="http://randamblings.files.wordpress.com/2010/04/day2.png?w=160&#038;h=300" alt="" width="160" height="300" /></a></p>
<p>That&#8217;s my house! It&#8217;s quite accurate here &#8211; I&#8217;m actually around where the little guy&#8217;s arm is, but GPS isn&#8217;t so accurate inside. If I go outside it&#8217;s a bit more accurate. This should be more than accurate enough for my application anyway, as it&#8217;s for outside use anyway. Also, it turns out that the MyLocationOverlay class does a lot of the stuff here for you. When I put both my own function and the MyLocationOverlay on the map though, they were almost identical, and at least I learned some things from this. MyLocationOverlay also displays the accuracy, and can give you a compass.</p>
<p>Note: Since this is my University project, I&#8217;m not going to put all the source code on here, and the bits I do paste will probably be fairly useless on their own. If you do happen to come across this page looking for information though, I&#8217;ll post some links that were helpful each day. You can also email me questions at android@lc8n.co.uk</p>
<p>Useful information for the day:</p>
<p>The HelloMapView tutorial on the Android Developer site is a great place to start:</p>
<p>http://developer.android.com/guide/tutorials/views/hello-mapview.html</p>
<p>Be sure to follow all the instructions for getting an API key! If you don&#8217;t get this right you won&#8217;t see any maps. You need to run the keystore program and then enter this string into the website. You can use the debug key for everything until you plan on adding your app to the market.</p>
<p>http://code.google.com/android/add-ons/google-apis/mapkey.html</p>
<p>This is a useful tutorial. A lot of it deals with using the address book and converting addresses to GeoPoints, but there&#8217;s some useful stuff there</p>
<p>http://blogoscoped.com/archive/2008-12-15-n14.html</p>
<p>This is another useful tutorial about GPS functions. Note that you need to click on the &#8220;Listing&#8221; links to get the source code. Some of it didn&#8217;t work quite right for me, but if you&#8217;re using Eclipse it should have a fairly good idea of how to correct it.</p>
<p>http://www.devx.com/wireless/Article/39239/0/page/1</p>
<p>Tomorrow I plan to try and add orientation/bearing data, and maybe see if I can get data from Google Maps about specific addresses on there.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/62/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/62/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/62/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=62&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/06/day-2-mapviews-and-locations/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>

		<media:content url="http://randamblings.files.wordpress.com/2010/04/day2.png?w=160" medium="image">
			<media:title type="html">Day 2: MapView and Location</media:title>
		</media:content>
	</item>
		<item>
		<title>Race against time</title>
		<link>http://randamblings.wordpress.com/2010/04/05/race-against-time/</link>
		<comments>http://randamblings.wordpress.com/2010/04/05/race-against-time/#comments</comments>
		<pubDate>Mon, 05 Apr 2010 17:43:39 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[lc8n]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=58</guid>
		<description><![CDATA[Right, it&#8217;s been over a year since I updated this blog, and now I&#8217;m going to revive it. Here&#8217;s why. I currently have 1 month left until the deadline for my final university project. I haven&#8217;t started coding it yet. It&#8217;s going to be a long month. I&#8217;ve decided to document the development progress, partially [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=58&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>Right, it&#8217;s been over a year since I updated this blog, and now I&#8217;m going to revive it. Here&#8217;s why.</p>
<p>I currently have 1 month left until the deadline for my final university project. I haven&#8217;t started coding it yet. It&#8217;s going to be a long month.</p>
<p>I&#8217;ve decided to document the development progress, partially since it&#8217;ll make it easier when it comes to writing the final report at the end, partially for my own amusement, and partially in the hope that could be of interest to other people if the project goes as planned.</p>
<p>The project I&#8217;m working on is a mobile application for Android. Android is Google&#8217;s answer to the iPhone, their own mobile OS which has been building momentum rapidly over the past year, and is the power behind some of the best  new mobile phones, such as the HTC Desire.</p>
<p>The basic idea of my application is that you take your phone, you point it at a location, and it tells you what you&#8217;re looking at. My original idea was to use image recognition to work out what you&#8217;re looking at through the camera, though this turned out to be far too complicated. It was then suggested that I could use the phone&#8217;s built in GPS and compass to reach a similar result. The location could then be compared to a database, either custom made or freely available (such as Google maps) to get location information.</p>
<p>Then I found out it&#8217;s been done before, by Layar. But, I was commited to it by this point, so I decided to go ahead with it.</p>
<p>Layar has evolved into a very popular application with a large team working on it. I have 1 month and 1 person to create something similar. It&#8217;s going to be a busy month.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/58/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/58/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/58/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=58&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2010/04/05/race-against-time/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>
	</item>
		<item>
		<title>Blu-Ray Shmu-Ray</title>
		<link>http://randamblings.wordpress.com/2008/10/31/blu-ray-shmu-ray/</link>
		<comments>http://randamblings.wordpress.com/2008/10/31/blu-ray-shmu-ray/#comments</comments>
		<pubDate>Fri, 31 Oct 2008 20:03:08 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[technology]]></category>
		<category><![CDATA[blu-ray]]></category>
		<category><![CDATA[computer]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=56</guid>
		<description><![CDATA[So, I finally got a shiny copy of Iron Man in the post a couple of days ago. I never got to see it at the cinema because of exams and stuff, and I didn&#8217;t want to download a crappy videocamera version of it. In the end, by the time it was finally released on [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=56&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, I finally got a shiny copy of Iron Man in the post a couple of days ago. I never got to see it at the cinema because of exams and stuff, and I didn&#8217;t want to download a crappy videocamera version of it. In the end, by the time it was finally released on DVD, I had a job, and a laptop that can play Blu-rays, so I thought why not buy the extra-special Blu-Ray edition of Iron Man.</p>
<p>Now this would be great, except for some reason my laptop can&#8217;t even handle playing Blu-rays. It plays, sure, but it it stutters as much as&#8230;a thing that stutters. One of these days I might think of some good metaphors. While the audio generally plays smoothly, the video is far from smooth. It plays along jerkily, and &#8220;seconds per frame&#8221; would be a more accurate measurement of the speed than &#8220;frames per second&#8221;</p>
<p>I&#8217;ve tried so many different things now that I&#8217;m sick of the sight of the opening Paramount logo, and AC-DC&#8217;s &#8220;Back in Black&#8221;, which plays through the first scene in Iron Man, is probably going to be circulating through my head all night.  Every time accompanied by a slow video that often grinds to a halt after 2 minutes. I did manage to get it to play at an almost acceptable speed one time, but when I realised I needed to check my emails, it slowed down back to it&#8217;s previous unwatchable speed.</p>
<p>I don&#8217;t know why this is. I see no reason why my computer couldn&#8217;t run a blu-ray. Sure, it&#8217;s the height of movie technology, but at the end of the day it&#8217;s just a video. A very high quality video, yeah, but that&#8217;s why it&#8217;s on a 50gb disk, I don&#8217;t see why it should take massive amounts of processing power to run. It does though, eating up over half of my CPU and memory power.</p>
<p>I&#8217;m wondering if this is just because the bundled software I have on my computer for playing blu-rays sucks. It doesn&#8217;t seem too great, but it&#8217;s hard to compare. Apparently the Blu-ray Disk Association, the smart people who designed the blu-ray technology, have decided that it&#8217;s a good idea to not actually tell many people how to make programs that play blu-rays. None of the standard freeware media players will play it. Not Windows Media Player, not VLC Player (which can play ANYTHING), nothing. If you want to play blu-rays you have to pay a higher price</p>
<p>I tried downloading a trial version of PowerDVD, one of the few programs which does support it. But no, the trial version won&#8217;t let you play blu-rays, you need to just buy the full version before you can so much as see the opening credits. The prices for the program aren&#8217;t BAD, £30 for software is certainly better than paying £300 for a blu-ray player of a PS3, but I already paid £600 for my laptop. And even though I do have a job now, I&#8217;m not willing to just drop £30 on some program that MAY or MAY NOT fix my problem. I don&#8217;t ask for much from the trial version, but why can&#8217;t it at least let you play 10 minutes of a blu-ray just to see if it will do what you need it to do?</p>
<p>For all I know it could just be that my computer sucks. I&#8217;ve had varied results from killing various windows processes (Vista seems to eat up a lot more CPU power than XP, no surprise. And McAfee just WON&#8217;T DIE, like some sort of digital medusa, as soon as I kill one process, 2 more pop up in it&#8217;s place. I tried downloading driver updates for my drive, but that doesn&#8217;t recognise the drive correctly and it just kills it until I restart. The disk drive manufacturers site tells me I need specific drivers from my laptop manufacturer, but they don&#8217;t have any mention of blu ray or disk drives in their driver section.</p>
<p>So now I&#8217;m back to the trusty old method of downloading the software off of bittorrent. While I do try to avoid pirating software these days when it usually isn&#8217;t necessary, there are some things I take exception to. Massive price tags, and software that provides no alternatives. Things like Photoshop fit into the first category, while programs like Microsoft Office do in fact offer suitable alternatives, like a student version for £40. Of course for things like that there&#8217;s always something like OpenOffice which will pretty much do the same thing for free.</p>
<p>But if they refuse to provide me with working blu-ray software for free, then&#8230; I&#8217;ll just get it for free anyway.</p>
<p>I just want to watch Iron Man. Is that too much to ask?</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/56/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/56/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/56/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=56&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2008/10/31/blu-ray-shmu-ray/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>
	</item>
		<item>
		<title>I&#8217;m not annoying enough to make money from it</title>
		<link>http://randamblings.wordpress.com/2008/10/09/im-not-annoying-enough-to-make-money-from-it/</link>
		<comments>http://randamblings.wordpress.com/2008/10/09/im-not-annoying-enough-to-make-money-from-it/#comments</comments>
		<pubDate>Thu, 09 Oct 2008 18:25:01 +0000</pubDate>
		<dc:creator>Joe</dc:creator>
				<category><![CDATA[Life]]></category>
		<category><![CDATA[jobs]]></category>
		<category><![CDATA[money]]></category>
		<category><![CDATA[work]]></category>

		<guid isPermaLink="false">http://randamblings.wordpress.com/?p=54</guid>
		<description><![CDATA[So, I lost my job after only 2 shifts. I&#8217;m usually pretty good with jobs, my bosses have always been happy with me, and one even went out of their way to find another job for me even when they didn&#8217;t need me any more. So it was a bit of a shock to be [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=54&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>So, I lost my job after only 2 shifts. I&#8217;m usually pretty good with jobs, my bosses have always been happy with me, and one even went out of their way to find another job for me even when they didn&#8217;t need me any more. So it was a bit of a shock to be told not to come back again after only 2 shifts.</p>
<p>To be honest, I was thinking that I&#8217;d start looking for something else already after just half an hour today. I knew I wouldn&#8217;t be able to put up with the job for long, but I figured I could at least bear it for a while until I found something else. But, yesterday was not my day.</p>
<p>I won&#8217;t miss the job, that&#8217;s for sure. I am pretty worried now about finding another. I spent most of last year looking for a job near college, I couldn&#8217;t find much. I had 2 interviews, which I thought went well until they asked about my availability, and I told them that I wouldn&#8217;t be around in the holidays. In hindsight, I should have just lied then quit when it came to the holidays.</p>
<p>This job as one of those jobs I swore I&#8217;d never do though. Telemarketing, outbound calls, being an annoying person who no one wants to talk to. Getting paid for being annoying doesn&#8217;t sound too bad, until you realise you have to be good at it. I, unfortunately (or fortunately maybe) am not.</p>
<p>A quick outline of what I had to do. I&#8217;d go through a big list of phone numbers, calling people and trying to ask them a few questions. Usually it&#8217;d go like this -</p>
<p>&#8220;Good evening, is this Mr/Mrs ___? Hi, I&#8217;m calling from Midas, we&#8217;re carrying out a brief holiday survey&#8221;<br />
&#8220;Not interested&#8221;<br />
&#8220;I&#8217;m not trying to sell anything&#8221;<br />
*Hang up*</p>
<p>Of course, the bit about not trying to sell anything was a bit of a lie. In these surveys, when you eventually got someone willing to answer them, we&#8217;d ask them a bit about how often they take holidays and where they like to go, while quickly moving onto some totally unrelated and somewhat too personal questions about their marital status and income. This was just so a precursor for a second call though. If they were married, earned enough money, and liked taking holidays, someone would call them back a week later and try to sell them a holiday.</p>
<p>I did alright on my first day. The people who were good at it would get 20 or so successful answers out of their lists in a shift. I managed 7, which wasn&#8217;t too bad considering I spent the first hour training and filling out forms, and I was new too it.</p>
<p>I&#8217;m not too sure what went wrong yesterday though. It might have been bad luck with the numbers I had, not many people answered, and most of those who did were too old (one of the requirements was that they be between 25 and 65). But still, when people did answer I rarely got them to actually answer the questions. I tried various ways of wording it, and it just didn&#8217;t work out.</p>
<p>My boss, team leader, or whatever they called themselves, spent most of the evening listening in on new people&#8217;s phone calls and giving them some advice. For me though, they were just condescending and insulting, telling me that my results so far were pathetic but offering me little advice on how I should improve. All she did say was that I needed to sound more cheerful and like I &#8220;wanted to be there&#8221;. Well, I didn&#8217;t want to be there. Ironically, I was actually pretty cheerful at the start of the shift, since I&#8217;d been having a pretty good week up until that point. But then it was a downward spiral from there, unsuccessful calls and an insulting boss did not do much to cheer me up.</p>
<p>Honestly, I have no idea how the people who work there can keep up their cheerful fascades for 4 hours. There was one girl who&#8217;s calls I listened in on during training last week. I actually had to hold the phone away from my ear, her voice was so annoying. I can imagine that the people on the other end of the line just wanted to answer the questions just to get her to stop talking. Some people just have a knack for stopping them from hanging up, and manage to persuade half the people to stay on the line. I&#8217;m too nice to them though. I just go &#8220;Oh ok, sorry for wasting your time, good bye&#8221;</p>
<p>So in the end yesterday, I got 4 successful calls compared to the target of 20. I tried to ask for one more chance in the hope I&#8217;d be a bit better after some more sleep, but that didn&#8217;t work. They just said it&#8217;d be a waste of their time if I came back.</p>
<p>I really do need the money though. There&#8217;s the website stuff I&#8217;m going to do too, but I don&#8217;t know if that&#8217;s enough to save up for stuff I want. Well, back to looking for jobs I guess.</p>
<br />  <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/randamblings.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/randamblings.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/randamblings.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/randamblings.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/randamblings.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/randamblings.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/randamblings.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/randamblings.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/randamblings.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/randamblings.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/randamblings.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/randamblings.wordpress.com/54/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/randamblings.wordpress.com/54/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/randamblings.wordpress.com/54/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=randamblings.wordpress.com&amp;blog=2394070&amp;post=54&amp;subd=randamblings&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://randamblings.wordpress.com/2008/10/09/im-not-annoying-enough-to-make-money-from-it/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://0.gravatar.com/avatar/e3167c014f0bdf2f10ca8946c3806737?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Joe</media:title>
		</media:content>
	</item>
	</channel>
</rss>
