Evert Van den Bruel: Android, Ruby, technology and gadgets

A random technology blog by @evertvdbruel

Google Maps V2 on Android

This post is a small tutorial on how to add Google maps v2 to your Android application. The v2 of the framework is a huge improvement over v1 since it was lacking all kinds of important features like gesture recognision, adding markers was realy annoying with ItemizedOverlay, …

So here are the steps needed to add Google Maps v2 to your application.

The first thing you need is an Android project, you can use an existing or create a new one. Once you’ve got the project you should download Google Play Services if you haven’t got them installed.

You can download via the Android SDK Manager (in Eclipse) wich is located at: Window => Android SDK Manager, “Google Play services” is located under extras.

While downloading you can generate the API key, go to the API console and create a new project. You’ll be redirected to a page with a bunch of switches, search for Google Maps Android API v2 and turn it on.

Once that is done you should open your terminal and get a SHA1 fingerprint of your debug key, so open a terminal window and enter
cd ~/.android
then
keytool -list -v -keystore debug.keystore
and copy the value after SHA1: value to be copied.

After that you should go to API Access and click on “Create new Android key…”, paste the value and add your package name (separated by a semicolon). Like this: 45:B5:E4:6F:36:AD:0A:98:94:B4:02:66:2B:12:17:F2:56:26:A0:E0;com.example

Now you should be seeing the Android key under API access.

Head back to Eclipse

Add the Google Play services project to the eclipse workspace: File => Import => Android => Existing Android Code Into Workspace, and select the folder <android-sdk-folder>/extras/google/google_play_services/ (where <android-sdk-folder> is your Android SDK location).

After that right click the project where you want to add the map and select Properties => Android => Add and select the google-play-services_lib project.

Open the AndroidManifest.xml in the xml view(select AndroidManifest.xml at the bottom of eclipse) and add the following lines under the root manifest tag:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
<uses-feature
        android:glEsVersion="0x00020000"
        android:required="true" />

    <permission
        android:name="com.example.mapdemo.permission.MAPS_RECEIVE"
        android:protectionLevel="signature" />

    <uses-permission android:name="com.example.mapdemo.permission.MAPS_RECEIVE" />
    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
    <uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />
    <uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />

Include the following in the application tag and replace your_api_key with the API key value from the Google API console

1
2
3
<meta-data
            android:name="com.google.android.maps.v2.API_KEY"
            android:value="your_api_key" />

Your manifest file should look like this

After that open activity_main.xml(or an other activity layout file you want to use) and replace the content of the file with

1
2
3
4
5
6
<?xml version="1.0" encoding="utf-8"?>
<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/map"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    class="com.google.android.gms.maps.MapFragment" />

Once this step is completed you should be able to launch the application on your device(maps do not work on emulators) and see a working map.

The source of this project is available on github.

Feel free to ask questions in the comment section.

Netflix Outside the United States?

Getting American flavoured internet

A few weeks ago I was wondering if it was possible to use Netflix in Belgium, so I started searching the web for ways to achieve this.

I came across quite a VPN services during this quest but the one that looked the most promising to me hidemyass.com (please note that is a referral link). One of the main reasons that I chose hidemyass was that you can configure it on a router so it’s possible to use Netflix(or any other country limited service) on your Playstation, Xbox, Apple TV,… but you can just install the client on your computer and use your browser.

If you want to use a router for this you need that you can flash DD-WRT on (you can check it here). Since I didn’t have an old router I started looking online for a cheap router that I could use and bought the TP-Link TL-WR1043ND on Bol.com or you can get it on Amazon.co.uk. Next I flashed the DD-WRT firmware on the router using the instructions found here. After that I configured the hidemyass settings on the router like this. When everything is setup correctly you can start exploring the American internet.

By default the Netflix application is hidden on most non-American devices I guess for not frustrating users with an unusable app so you need to change the region to USA.

  • Apple TV: Settings > General > iTunes Store > Location and choose United States
  • Playstation 3: create a new ps network account and choose United States as region, log in on your device and download Netflix

The only thing left before you can start enjoying the Netflix goodness is registering an account.

Thoughts after one month

I’m realy loving every moment I’m using my setup here are some reasons:

  • the amount of content with stuff like:
  • Netflix original content (coming soon)
  • pickup where you left in your on ‘any’ device
  • access other exclusive content like the US google play store, so you can get books, movies, … on your Android
  • content starts at the press of a button
  • allmost everything has English subtitles
  • recommendations on things to see based on your ratings

And a few negative points:

  • Netflix hasn’t got all the content :], but there are other services like hulu, hbo, … so you can get extra content if you like
  • due to the latency surfing isn’t a solid experience (no problems with streaming)

Conclusion

Watching content never has been easier for me fire up the application, select the video you want to watch, press play and you’re done. So I would recommend using netflix to anyone who loves consuming tons of content.