Accepting incoming tcp ip connections in (K)ubuntu

I’ve recently spent a bit of time trying to work out why I could accept incoming connections on my Kubuntu laptop. Initially I tried to get Charles to work but couldn’t get it to see any traffic coming from my Android phone – I put it down as a bug in Charles and left it. Today I tried to get Synergy working and again nothing, which prompted me to investigate further. I know Synergy was working on my laptop as a client, but I was trying to make it a server today, and it wasn’t showing anything being able to connect. This sounded very much like I was behind a firewall – but to the best of my knowledge I don’t have a firewall on my laptop. Anyway, turns out the ports were closed and the following command allowed me to open them (24800 for Synergy, Charles works on port 8888):

sudo iptables -I INPUT -p tcp --dport 24800 -j ACCEPT

Read More

Time to update your support library

Fragmentation is an often cited issue of the Android ecosystem, but the people who really bear the brunt of it are not so much the end users, but the developers who have to create applications to support multiple versions of the platform. It’s for this reason Google created the Android Support Library – used to provide backwards compatibility for newer features of Android.

Originally released in March 2011, just after the introduction of fragments in Honeycomb (Android 3.0), the support library (originally called the “Android Compatibility package”) provided developers the means to use Fragments, LoaderManagers and a few other classes across mostly all versions of the platform, going back to Donut, version 1.6. This library, combined with the excellent ActionBarSherlock , gives developers the means to write a single codebase which can support multiple versions of the platform without having to write platform specific code – the only exception that comes to mind being the ActionBar action view widgets which need specific pre-ICS implementations.

Fast forward a couple of years to Google I/O 2012 and the, now named, Support Library is on revision 9 and has brought with it a lot of updates. Google is slowly implementing functionality which has, up until now, been developed by other people. For example, revision 9 includes a lot of bug fixes and new functionality to the ViewPager class, however note currently the ViewPageIndicator library still offers better functionality. The Notification Builder has also been updated, but again note that a third party library, in the form of the NotificationCompat2 library, is still the recommended way to provide complete support for notifications across all platform versions without sacrificing the newer functionality where available.

Of particular interest, and the reason for the title of this blog post, are the ‘many bug fixes’ for the Fragment class, which by now should be core building blocks used by all Android developers (if you aren’t using them yet – what are you doing?!) – this in itself should be reason enough to update.

Google seems to update Android everytime it release a new Nexus device, and if the rumour-mill is correct then we should be seeing a new Nexus handset at some point towards the end of the year. If past updates are anything to go by, Google should be releasing another updated version of the Support Library sometime in August 2012 or shortly after. It’s strongly adviced to keep an eye on the Support Library updates and implement new versions as soon as they’re released in order to take advantage of the new features and bug fixes.

Read More

Getting a YouTube clip to run inside your Android application

Recently I’ve been working on an application for a company based near to where I live – part of their application involves some video in the app. Now Android has a 50 meg limit on apk files in the market, so I was tasked with streaming the videos from YouTube, which doesn’t seem to be a massive problem up front.

How wrong I was.

Getting YouTube videos to stream inside an Android app is actually really difficult – I hunted for hours on StackOverflow.com looking for something which would work, only to be given half baked code or ill-thought-out solutions. I got something working by faking the browser agent and loading the video directly, but this would only work in Android 2.x and then only if the user has Flash installed.

So I wrote to my client – telling them that I’d already spent quite a lot of time on this, and that I wanted them to make a call on how best to proceed…and about 30 minutes later I found the answer. Open YouTube Player is a fantastic bit of code, written by Keyes Labs which you can pretty much drop in to your code to get working. It looks like it’s dependant on the way YouTube encodes their videos, so if that changes then it may break, but the project is active on and it’s the best solution I’ve found.

I hope this saves someone else a lot of hunting the internet for a solution to this problem, and a massive thanks to Keyes Labs.

Read More

Book review : Android Wireless Application Development

Original review posted on the Barnes & Noble site.

As a seasoned Android developer it’s easy to forget the steps necessary in getting up and going with the platform – Conder and Darcey do a very good job of explaining the basics, with a small taster of the more complex stuff, with plenty of code examples to help along the way and just enough levity to keep the experience engaging (I also want to call my pet Null!) For someone new to the platform this is definitely a book you can read the first third of without skipping any, and then refer back to as a reference guide as and when needed.

The middle parts of the book, where the more complex ideas come in, aren’t full enough to be of any real use – the OpenGL and NDK sections could have multiple books written about each. I’m stuck between wondering if they are a nice, but brief, introduction which people will find useful to whet the palate, or short enough, and not detailed enough, to be of no real use and to warrant not being included in the first place. The latter parts of the book include some useful guides for testing and selling you Android app, as well as some short but useful sections on Eclipse; the emulator; SQLite and ADB. I found there were a few items I would have liked to have seen some more info about (i.e. broadcast receivers receive very little attention), and there were a few small coding mistakes throughout the book. The order of the sections in the latter half of the book also looked like they could have had a little more thought applied to them.

Overall this is a solid book for getting up to speed with Android development and the negative points are small enough so as to not distract from the overall learning experience. It’s not a book you are going to keep forever as once you learn the basics you’ll want to move on to other fuller, and more detailed, sources.

Read More