Thursday, August 23, 2012

Getting the street address..and errors :-/

I was testing my app, it should update the latitude and longitude of the phone when it moves more than 10 meters or passes some time.
After updating the lat/long also the address reverse geolocation it's done.

While I was walking in the office yard (almost naked under 40° sun) I got the following error :

java.io.IOException unable to parse response from server

Got quite frightened, but the Saint Google again come in handy.
This just means that I did too much geolocations requests to the google server, so I got kicked out for a while.

Not a big problem, just wait for some time or restart your app and everything goes fine again.


Using Dialogs and Java1.5 vs Java1.6

Trying to display a MessageBox to the user of my awesome app.
Found a simple example on (thanksgoditexists) Google.
The code looks as follows :


AlertDialog ad = new AlertDialog.Builder(this).create();  
ad.setCancelable(false); 
ad.setMessage("GPS Disabled");  
ad.setButton(DialogInterface.BUTTON_POSITIVE,"OK", new DialogInterface.OnClickListener() {  
@Override  
public void onClick(DialogInterface dialog, int which) {  
               dialog.dismiss();                      
           }  
});  
ad.show();

By compiling this code Eclipse gave me the following error :

method onClick(DialogInterface, int) of type new DialogInterface.OnClickListener(){} must override a superclass method

Here is why :

Eclipse is defaulting to Java 1.5 and you have classes implementing interface methods (which in Java 1.6 can be annotated with @Override, but in Java 1.5 can only be applied to methods overriding a superclass method).
Go to your project/ide preferences and set the java compiler level to 1.6 and also make sure you select JRE 1.6 to execute your program from eclipse.


Happy coding!

Android Development Experiences

Finally I got my Android phone...an old Galaxy Next (not the turbo edition).

Running apps on the phone is really easy and no problems encountered.
As soon as I've choosen to run the emulator I've encountered a problem.
The Eclipse interface told me that libGL.so was missing.
The libGL.so comes with the libgl1-mesa-dev package, so if you have not installed it just do a

sudo apt-get install ligbl1-mesa-dev

In my case I already got libgl mesa as I was developning OpenGL already, so
the solution was to create a link in (Ubuntu 12.04 64bit) mesa folder like this.


ln -s /usr/lib/i386-linux-gnu/mesa/libGL.so.1.2 /usr/lib/i386-linux-gnu/mesa/libGL.so

Hope this helps if someone finds the same problem.

Happy coding folks.