Skip to content

Instantly share code, notes, and snippets.

@Andrewpk
Last active August 29, 2015 14:25
Show Gist options
  • Save Andrewpk/b0ef2a755d37f582f6dc to your computer and use it in GitHub Desktop.
Save Andrewpk/b0ef2a755d37f582f6dc to your computer and use it in GitHub Desktop.
String + Uri.parse() vs Uri.parse().buildUpon(). I'm probably missing something, but why does Android 2.3 have problems with using Uri.parse().buildUpon() when every one of these methods has been around since api v1?
/**
* Works great on Android 4, and likely 3 but causes Android 2.3 to build a Uri
* with a string value of "geo:?q=" + zipCode
*/
Uri geoUri = Uri.parse("geo:0,0?").buildUpon()
.appendQueryParameter("q", zipCode).build();
/**
* Works great on Android 2.3+
*/
String fullUri = "geo:0,0?q=" + zipCode;
Uri geoUri = Uri.parse(fullUri).buildUpon().build();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment