Implementing URL Handling in the Android App

I've tweeted about this to the Verge Support team recently, but I know they might have a lot on their hands right now. So I thought I'd show just how easy this could be to implement. Any other Android developers please point out any obvious mistakes I make.

First, in your AndroidManifest.xml file, add this(replace -'s with s):

-receiver android:name="UrlHandlerReceiver"-
		-action android:name="android.intent.action.VIEW" /-
		-category android:name="android.intent.category.DEFAULT" /-
		-category android:name="android.intent.category.BROWSABLE" /-
		-data android:scheme="http" android:host="" /-
		-data android:scheme="http" android:host="" /-

Second, create a new class called UrlHandlerReceiver

// imports here

public class UrlHandlerReceiver extends BroadcastReceiver {
	public void onReceive(Context context, Intent intent) {
		Uri uriInfo = intent.getData();
		List pathSegments = uriInfo.getPathSegments();
		//Conditional to test if they was a path
		if(pathSegments.size == 0) {
			//start MainActivity
		} else {
			// Test for article, video, podcast, comments, forum post, launching appropriate activity



And that's it! One of your talented engineers could probably work out the conditionals in an afternoon, and you could write unit tests quickly, and ship this feature by E.O.B. And it makes looking at the Verge on Android devices 1000x more enjoyable. Thank you Verge Product team for making so much awesome stuff, hopefully you implement something similar to the above and make the Android app even more awesome.