seatgeek / api-support

A support channel for the SeatGeek Platform
9 stars 7 forks source link

Android app no longer handles seatgeek URIs #6

Closed MarkBryanMilligan closed 8 years ago

MarkBryanMilligan commented 8 years ago

Previous versions of the SeatGeek android app would allow me to pass in an event id. I did this using the following code:

if (getContext().getPackageManager().getLaunchIntentForPackage("com.seatgeek.android") != null)
{
    StringBuilder url = new StringBuilder("seatgeek://events/");
    url.append(<event_id>);
    url.append("?aid=");
    url.append(<partner_id>);
    getContext().startActivity(new Intent(Intent.ACTION_VIEW, Uri.parse(url.toString())));
}

When I do this now, my app crashes because the seatgeek app can no longer handle this URI pattern. What is the correct way to launch into the seat geek app passing it an event context and a partner id?

dallasgutauckis commented 8 years ago

Hey, Android engineer here. This is a regression and a fix should be out in the next few days. Apologies for the inconvenience.

MarkBryanMilligan commented 8 years ago

That's great news, thanks for the quick response.

dallasgutauckis commented 8 years ago

No worries. Sorry for the incomplete response, I wanted to get back to you on your second question on "what is the correct way…"

You're launching in an acceptable way, though this can—as you've seen—be problematic in this type of scenario where the package you're asking about doesn't support the URI you're trying to give it. You can absolutely safeguard from this by also wrapping in a try/catch block the startActivity(…) call.

Alternatively, you can use http://developer.android.com/reference/android/content/pm/PackageManager.html#resolveActivity(android.content.Intent%2C%20int) to resolve the Activity that will handle the given intent (in this case an intent with a URI) and determine if there are zero results, thus allowing you to fall back to an HTTPS URI.