Archive for December, 2009

Android – Handling Screen Rotation

December 30th, 2009 @ 7:31 pm

0

androidLogo

Word of warning before we start, this goes against the standard Android UI and should only be done when you are certain it is appropriate.

To handle screen rotations such that your activity doesn’t get destroyed and restarted do the following:

  1. In your AndroidManifest.xml file go to the Application tab (Assuming you are in Eclipse, Manual programmers can still use this info, but will need to work out the corresponding xml), then under Application Nodes select the Activity you want to stop the rotations on, on the right hand side under “Attributes for <Class Name> (Activity)” scroll down to  Screen Orientation and set it to portrait or landscape.
  2. Then in the same section set config changes to “orientation|keyboardHidden”
  3. Now back in your class add the following function and you’ll be good to go.
// Handle Screen Orientation (Stop Activity being killed and re-started)
@Override
public void onConfigurationChanged(Configuration newConfig)
{
super.onConfigurationChanged(newConfig);
}

// Handle Screen Orientation (Stop Activity being killed and re-started)

@Override

public void onConfigurationChanged(Configuration newConfig)

{

super.onConfigurationChanged(newConfig);

}

Tags: ,
Posted in Uncategorized | No Comments »

Google Maps on Android Checklist

December 30th, 2009 @ 5:27 pm

2

Google Maps Logo

Your making an Android app and want to take advantage of Google Maps, you’ve been bashing your head against the desk attempting to work out what is going wrong.

So welcome to this little checklist of things I’ve forgotten to do when doing this task:

  1. Right click on your project in eclipse and go to properties. Then under Android select Google APIs with the correct platform number, click apply then Ok
  2. Open up your Android Manifest file, under the application tab scroll to the bottom and under the Application Nodes click on Add, then double click on “Uses Library”, now for the name enter the following – com.google.android.maps
  3. Your activity which is going to be displaying the map isn’t a plain old activity, it needs to be a MapActivity like: public class MapExample extends MapActivity
  4. Finally your map view in the layout file should look something like <com.google.android.maps.MapView android:id=”@+id/mapview” android:layout_width=”fill_parent” android:layout_height=”fill_parent” android:clickable=”true” android:apiKey=”YOUR_API_KEY”/> where your api key can be found by doing as mentioned on the Google Maps site -http://code.google.com/android/maps-api-signup.html

This should get you up and running with lots of mappy goodness.

Tags: , ,
Posted in Uncategorized | 2 Comments »

Handling Facebook Date/Times

December 28th, 2009 @ 5:19 pm

0

Facebook Logo

Today I was playing around with the facebook api and needed to extract the date and time for each event. When you look at the value from the api call, you get something along the lines of:

1262028000

For the date of the event from the facebook event page, is 28th Dec 09 11:20, so what is the result above all about? Well it’s Unix Epoch Time representation of the time, however the wonderful folks of facebook convert the time into pacific time, before then converting it to Unix Epoch time. So in php to extract the date/time in your local time zone do the following:

date_default_timezone_set(‘America/Los_Angeles’);

$startDate = date(‘d m Y H:i’, $eventInfo['start_time']);

and this will give you a time like this:

28 12 2009 11:20

I can’t take any of the credit for this, all of it has to go marc2003 over at forums.overclockers.co.uk.

Anyone looking for more info on handling facebook events api I strongly recommend this site – http://www.phpeveryday.com/articles/Facebook-Programming-API-Events-P852.html

Tags: , , ,
Posted in Uncategorized | No Comments »

Android Losing It’s Edge?

December 9th, 2009 @ 11:28 pm

0

androidLogo

After attending one of the Google Developer days in London, I couldn’t help but think that Android is going down a bit of a bad road, taking away some of the simplistic things that made it such a perfect platform to develop for.

So in the good old days of Android, you downloaded a single SDK and everything worked, now you have to download it, and then run an application inside the SDK to install the required versions of code (which actually wasn’t all that obvious to me when I needed a new install of the SDK). But as the day progressed and I got to play with a load of devices, you quickly see that the OS versions on each device become a big problem. (more…)

Tags:
Posted in Uncategorized | No Comments »