May 122011

Gone are the days when the web was a one-size-fits-all kind of global information vending machine. In the past few years, continuous efforts are being made towards making the web as local as possible, with websites being able to present content suited to the users browsing it.

One huge component of this new wave are the development of location aware websites. Websites which give relevant information without the user having to explicitly search for it. For e.g. A movie ticket booking website which can be used to book tickets in theatres all over the country. Very few people, if any would travel more than 20 km to watch a movie. Hence it makes business sense to display the theatres in the 20 km radius of the users location. Instead of subjecting the user to an information overload, the website is smart enough to simplify the entire process and cut down the time taken.

Geolocation isnt a new concept. Previously, websites used the IP address and did a lookup to get a rough idea of the user’s location. There were other methods like the locale setting too. So while framing the HTML5 spec, the W3C decided to arrive at a standard for providing the client’s location to the server which abstracts out the actual method used by the browser to determine it (Cell tower triangulation, IP address, GPS etc). Since its a privacy concern to reveal one’s location, the whole geolocation API depends on explicit permission separately provided for each website.

I created an example page which integrates Google Maps API and geolocation and displays a map as per the user’s location. Since not every browser would be able to support geolocation yet, I used the JS library Modernizr which detects whether the feature is supported by the end browser without us having to do the browser sniffing using the user agent. Here is the script code.

 * Title: Geolocation API access
 * Author: Ganesh Ranganathan

var map; //global variable for the map object
	//this is the default latitude /longitude to be set on the map
	var latlng = new google.maps.LatLng(-34.397, 150.644);
	var myOptions = {zoom: 8,
			center: latlng,
			mapTypeId: google.maps.MapTypeId.ROADMAP};

	//Map constructor which creates the map
	map = new google.maps.Map($('#map_canvas')[0],myOptions);

	//Modernizr is a JS library which lets us check if
	//the target browser supports these features
		printMsg('Waiting for permission from you',false);
		//The getCurrentPosition takes in two callbacks - one for
		//success and one for error. Both functions are defined anonymously
		//inside the method
			printMsg('Permission Granted: Your Coordinates are '+position.coords.latitude+
					 ' & '+position.coords.longitude);
			//This is executed if the getPosition is successfull. Moving the map to the user's location
			map.panTo(new google.maps.LatLng(position.coords.latitude,position.coords.longitude));
			//This is executed if the getPosition is unsucesfull.
			//Show the error reason to the user
			case error.TIMEOUT:
				printMsg ("Error: Timeout",false);
				printMsg ("Error: Position unavailable",false);
			case error.PERMISSION_DENIED:
				printMsg ("Error: Permission denied",false);
			case error.UNKNOWN_ERROR:
				printMsg ("Error: Unknown error",false);
	else //Print this message if GeoLocation itself isnt supported by the browser
		printMsg("geolocation is not supported on your browser",false)

//Helper function to set the status message to
//the span value
var printMsg = function(txt,append){
		var existingText = $('#statusMsg').text();
		$('#statusMsg').text(existingText+'  '+txt);

The getCurrentPosition method of the navigator.geolocation object takes in two functions as the parameters. First is the SuccessCallback and second is the errorCallback. The success callback is passed the position object which contains the location information like latitude and longitude. This is the simple markup for the page. Please note that the Modernizr, Google Maps, Jquery scripts are referenced in the order they are needed.

<script src="Scripts/modernizr-1.7.min.js" type="text/javascript"><!--mce:0--></script>
<script src="Scripts/jquery-1.6.min.js" type="text/javascript"><!--mce:1--></script>
<script src="" type="text/javascript"><!--mce:2--></script>
<script src="Scripts/scripts.js" type="text/javascript"><!--mce:3--></script>
<h1>Geolocation API with HTML5</h1>
<div id="status">
 <span id="statusMsg"> </span></div>

The demo page for this application can be seen at –

Here is the application when its run for the first time in Chrome. As you can see it asks for permission from the user. Meanwhile the map is centered towards the default location.

If we allow the application to access our location, then the map moves to the user’s coordinates – Bangalore in my case. Here is a screenshot – this time in Firefox

Since its a standardized API, the same code works for mobile browsers as well. Here are some screenshots of the page running on the Android stock browser which is also geolocation compliant.

After granting permission

Jan 122011

After seeing twitterati abuzz with claims of Google goggles being able to solve Sudoku puzzles, I decided to verify on my own. Turns out Goggles does solve the puzzles by itself, and within 10 seconds too.

It took artificial intelligence to the pinnacle when it emulated human behavior by changing a number from 6 to 9 in the top center square, to make the puzzle solving easier!! 😛

Here are the results. The original puzzle on the net  (

After scanning the puzzle from the computer monitor, this is what the Goggles app analyzed

And this after Goggles solved it, in all of 10 seconds!!

Dec 192010

The long standing advantage of Ovi maps touted by the few remaining Symbian enthusiasts was that it doesn’t need a working GPRS connection to run, while Google maps requires a connection to download the tiles. With the latest release, Google has rectified this minor disadvantage too. When Maps is on a wifi connection, it downloads tiles closer to your location and caches them so we can navigate even without having a GPRS connection.

You can control the cache size and enable offline downloading even when not on wifi. Titling works by using two fingers on top left and right of the screen and then dragging them down, which will turn the map into a 3D view and the buildings all become 3D. This isn’t available for all cities yet and the supported cities list can be found here. The 3D view doesn’t work for me yet, maybe because I am on a slower 2G EDGE connection, but you can see the video below for a demo of the features


Dec 182010

LinkedIn is the most popular professional social networking site in the world. It covers 200 countries with a user base of 85 million users. The 20th most popular website in the world, LinkedIn boasts of over 50 million unique views every month. Apart from being a very popular website, LinkedIn also has a significant mobile presence with having apps for both the Blackberry (duh!) and iPhone. With the ever increasing popularity of the Android platform, it isn’t a surprise that the LinkedIn decided to unveil a Android version of their mobile app.

The announcement of the beta came  this week and works for Android 2.1 and above. Below are the steps to install it.

  • Go to Settings -> Applications  and make sure the “Unknown Sources” option is checked. This will allow the installation of non market apps. (Screenshots for this step are given at the above link –
  • Download the .apk file from the link on the page and it will get saved on your SD card. Double click the app and install it. You can also use an app like “Apps Installer” which scans the SD card for all .apk files and allows installation.

The app is still in early beta, so there is a lot of functionality missing like ones given below. But don’t worry, LinkedIn has promised an update to the beta next year which will cover some additional features.

  • Groups are missing
  • You cannot access your inbox from the app
  • You cant reply to or share an update from a connection
  • You cant tweak your twitter integration settings yet

But one notable thing is the speed of updates. Even on my slow 2G EDGE connections, searches and updates were happening lightning fast. On 3G the application would work almost instantly.

First open the application from the phone’s home screen

After logging in, the application’s home page looks quite simple and and bare bones. Just 4 options for now

Clicking on Updates shows you a list of all the updates from your connections. I didn’t find a place to update my own status yet. There are no options to reply or like the updates from your connections. I tried the long press on this screen but it didn’t work, the only page that can be opened from here is the user info screen by clicking on the face of the connection.

Here is the user info screen. Notice there are two buttons here – Connections and Common Connections. Each opens another page which gives the connections of the user. A funny thing is that the first button seems to be disabled if the user has more than 500 connections (Notice there is no right arrow). I hope its only a temporary feature put in for the beta and this limit will be removed in the final version.

Coming back to the home page, The Invitations part seems to be still half baked. There is hardly any option here except to refresh and to invite any of your phone contact. I would love for a link to the search function which would allow me to search for a contact and then invite him directly.

The connections feature works as advertised and adds an additional feature of being directly able to email/call our contacts from the app itself. This is a very useful feature since all our connections may not be phone contacts.

The search feature is one more which is not yet fully developed. I tried searching for a company by its name but all I am got were the employees working there. Also there are no advanced filter features which exist in the website.

Verdict – 4/5

Except for the absence of some essential features because its an early beta, the LinkedIn app seems to be quite robust. There are no crashes and all options work as advertised. The developers deserve an applause for the speed of search and loading of updates which happens very fast on slower 2G connections. If they incorporate all the missing functions in the subsequent releases, I would be accessing LinkedIn on the mobile far more than the web version

Jul 272010

The number of apps in the Android market has been growing at a breakneck speed and soon looks to surpass 100,000, giving the iPhone app store a run for its money. The developer community has been showing some serious interest in developing apps for Android as well as contributing to the OS codebase. The lower entry fees (25$) as compared to the iPhone ($99), combined with the more liberal acceptance criteria has done much to fuel interest.

There are two kinds of contributions that interested developers can make to the Android platform. First is testing out and submitting patches to the Android codebase and the other is to write applications targeting the platform. The applications are to be written in Java which simplifies the development process by quite a bit. I wrote this post to show how to set up the Android development environment to write apps.

Before starting development, there are a few points every new mobile app developer should keep in mind. Though not an exhaustive list, it serves as a reminder of few crucial points.

A more comprehensive discussion can be found here.

  • The Java code that you write isnt compiled by the usual JVM but a lighter implementation called Dalvik. So a lot of compiler/runtime optimizations are unavailable to us yet. Just in Time Compilation has just been added in Froyo. Other optimizations like Method inlining, caching are not added so use direct fields where possible rather than properties.
  • Responsiveness is of paramount importance in a mobile OS. On a PC, people might not notice lags of a second or so, but on a handheld device, even the smallest of lags is instantly noticeable and decreases the user experience
  • Don’t take device display for granted. Android has been used on devices with varying display sizes – from phones to netbooks to tablet pcs. So while coding the layout, keep the appplication as end device agnostic as possible.

To get started, we need the following components.

  • Eclipse IDE (both Windows and Linux)
  • ADT plugin for Eclipse
  • Google SDK
  • Android platform components.

First the Eclipse IDE. This by the way, is the only step that would differ between Windows and Linux. All others are pretty much the same.

On Windows, the IDE can be downloaded from the site – and run the setup to install. Linux’s package manager makes the install a simple one step process. In the command line type

sudo apt-get install eclipse

Next, download the Google Android SDK from this page as per your platform. The MD5 checksums for the archive are given, so you can verify the integrity of the file after download. Expand the archive to the disk. Now we need to install the ADT plugin for Eclipse. To do that go to Help -> Install New Software. Here the site of the ADT plugin needs to be added – Once that is done click Add, and choose both  Android DDMS and Development tools and click Finish to install them

Now open Eclipse and choose Window -> Preferences -> Android. In the Options page, give the path of the folder where you stored the SDK.

Once that is done, we need to download the SDK components. These components differ for each API version. The higher the version goes, the more features you will get. But the number of devices your application will support would also decrease. So its always better to target the most stable current release which would be on a majority of devices. Go to Window ->Android SDK and AVD manager. In the Virtual Devices tab click Add and create a new Android Virtual Device. This is the emulator that we can use to test our applications on. Enter the required details and remember to set the memory card size above 10 MB. Once you Create the AVD, it will show up in the Virtual devices tab.

Then, select the Available packages tab in the same window and click on the plus sign next to the web address. This will give us the available packages which can be installed. Choose any one of your choice and click Install Selected.

Once the SDK is installed you will be able to create Android applicatons by Going to File -> New -> Project -> Android Project. In my next post I will explain how to write a simple Android application.

Jul 192010

AndroidVNC is an Android app that can be used to connnect and control a remote machine which runs a VNC server. There are many VNC servers available like RealVNC, TightVNC, X11VNC server etc. The VNC server listens to a port (typically 5900) which the VNC client, can connect to and view/control the machine remotely.

Running it on a machine is quite straightforward. All you need to do is to start the TightVNC service and connect it from the phone using the app that can be downloaded from the market. It works great and can be used to control your PC from anywhere as long as its connected to the net.

But when you want to connect to a machine running on a VM, things can get a bit tricky. Mainly because of the way VirtualBox works. The default networking mode between a Host OS and the guest OS is NAT (Network Address Translation), which makes the VirtualBox as an intermediary between the Host and the guest and maps traffic to and fro. Though this mode requires virtually no configuration, it also makes the guest OS inaccessible from the outside world. Since any VNC viewer requires connectivity to the VNC server running on a machine, this limitation was effectively a dealbreaker.

To avoid this, the packets which reach the host must be sent to the guest through some mechanism. VirtualBox provides such a mechanism to do it and the protocol is called SSH (Secure Shell) which allows two networked devices to exchange data with each other. What happens is we open a port on the host side and forward any data received to a specified port on the guest through TCP. However, the GUI interface doesn’t give this option, its in a command line tool called VBoxManage. Before running this command, get the local IP address from Ubuntu using the ifconfig command. The IP was

Now we need to tell VirtualBox to forward all data received on any specified host port to port 5901 on Ubuntu.
I used the port 2222. The command for this is given below. Keep in mind that the VM needs to be powered off to use this command. Here you need to substitute your VM name with VM_NAME_here parameter. The guestssh is just a name assigned to it and doesnt really matter. Next comes the protocol – TCP, followed by the port on the host 2222. The two values after it signify the local IP for the guest OS and and port on the guestOS which will recieve the data.

VBoxManage modifyvm "VM_name_here" --natpf1 "guestssh,tcp,,2222,,5901"

Now that forwarding is configured, power on the VM again and install any VNC server on Ubuntu. I used X11VNC for this exercise.

sudo apt-get install x11vnc vnc-java

After X11VNC is installed, start it by going to Applications -> Internet -> X11 VNC server. It will display a dialog asking for the options. Make sure the port is 5901 and click on OK.

After clicking on OK, in the next screen. Make sure the Accept Connections tab is checked and also give a password and click on Ok. The X11VNC should be visible on the top left of the screen (If you are using GNOME)

Now that VNC is listening to port 5901 on the server, you can test it by running a VNC viewer on the localhost and specifying the port 2222 and seeing if the connection is made. The host would be This connection should be forwarded to the Ubuntu’s 5901 and the connection should succeed. If not see the logfile of the X11VNC to see if the connection was rejected due to some reason.

If your all set, run the AndroidVNC application on your phone. Also a very important point – “If you are accessing the net through a slow connection such as GPRS, make sure the resolution on Ubuntu is set to the miminum to prevent timeouts.” Get the network IP of your host through ipconfig or a site such as and enter the required settings on your phone.

Nickname: Any nickname you want
Password : What you specificied on X11VNC
Address: The public IP of your computer you got from ipconfig.
Port: 2222

And hit connect. It might take upto a minute to draw the first frame. Once thats done, you will be able to completely control the computer from your phone.

You can also send text and other key commands to the VM from your phone using the app options. Just How cool is that??