Real Android fragmentation in the wild.

Lots of people have been banging on about Android fragmentation and that it is all going to end up like J2ME and we are all going to explode big splurge. I am pretty relaxed about this as fragmentation is just a fact of life in mobile – because we are dealing with consumer electronics after all – and to be honest it is just the natural state of things, look at all the browsers hacks people take for granted.

That said in creating the “VIP Call” app for Android I came across a real live fragmentation example and here it is:

VIP Call” depends on being able to access the Contacts on the phone via an intent like so:

Intent intent = new Intent(Intent.ACTION_PICK, People.CONTENT_URI);
startActivityForResult(intent, PICK_CONTACT);

and process the returned contact like so:

Uri contactData = data.getData();
Cursor c = activity.managedQuery(contactData, null, null, null, null);
if (c.moveToFirst()) {
String name = c.getString(c.getColumnIndexOrThrow(People.NAME));
String number = c.getString(c.getColumnIndex(”primary_phone”));
return new Vip(name,number);
} else {
return null;
}

This works fine in 1.5 and 1.6 but fails in > 2.0 – my Droid users were not happy.

Turns out the contacts API has been re-written pretty extensively for 2.x so that there is support for multiple accounts. What’s more it aint backwards compatible.

The solution – suggested by google – is to create a ContactsAccessor class that encapsulates the two different implementations. So the call to the Intent now looks like:

startActivityForResult(mContactAccessor.getPickContactIntent(), PICK_CONTACT_REQUEST);

I wont list the full solution here as Google have provided a full example solution in the android-business-card code.

I must say this bit of code in the solution gave me J2ME Vietnam-like flash backs:


/*
* Check the version of the SDK we are running on. Choose an
* implementation class designed for that version of the SDK.
*
* Unfortunately we have to use strings to represent the class
* names. If we used the conventional ContactAccessorSdk5.class.getName()
* syntax, we would get a ClassNotFoundException at runtime on pre-Eclair SDKs.
* Using the above syntax would force Dalvik to load the class and try to
* resolve references to all other classes it uses. Since the pre-Eclair
* does not have those classes, the loading of ContactAccessorSdk5 would fail.
*/
@SuppressWarnings(”deprecation”)
int sdkVersion = Integer.parseInt(Build.VERSION.SDK); // Cupcake style
if (sdkVersion < Build.VERSION_CODES.ECLAIR) {
className = “com.example.android.businesscard.ContactAccessorSdk3_4″;
} else {
className = “com.example.android.businesscard.ContactAccessorSdk5″;
}

Tis my own opinion that fragmentation in Android is going to be on a par with the fragmentation we find in the browser world rather than the J2ME experience. The major reason for this is that the Android OS is over the air upgradable – my G1 has already had about 3 upgrades – this was not possible in the J2ME giving us the long tail we know and love ;-) .

310 Responses to “Real Android fragmentation in the wild.”

  1. edward says:

    fredrikshall@dealerships.dialed” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

  2. Jared says:

    shiny@tacitly.portago” rel=”nofollow”>.…

    thanks….

  3. arturo says:

    darlay@resulted.combellack” rel=”nofollow”>.…

    ñïàñèáî çà èíôó!…

  4. nick says:

    basils@emissary.grizzly” rel=”nofollow”>.…

    hello….

  5. Chad says:

    bostons@dressers.integral” rel=”nofollow”>.…

    thank you!…

  6. Johnnie says:

    unreleased@injured.roys” rel=”nofollow”>.…

    áëàãîäàðþ!…

  7. Calvin says:

    elusive@boundless.emilio” rel=”nofollow”>.…

    tnx for info!!…

  8. Maurice says:

    possum@ts.stoves” rel=”nofollow”>.…

    ñïñ!…

  9. Joshua says:

    exposure@pessimists.dusted” rel=”nofollow”>.…

    good!!…

  10. brent says:

    ruthlessness@modernism.firsthand” rel=”nofollow”>.…

    áëàãîäàðåí….

  11. sidney says:

    strove@hardships.believe” rel=”nofollow”>.…

    ñïñ!…

  12. Johnny says:

    fresno@flopped.naktong” rel=”nofollow”>.…

    thank you….

  13. jeffery says:

    quirks@vitality.caskets” rel=”nofollow”>.…

    good info….

  14. Joey says:

    ellisons@tore.juras” rel=”nofollow”>.…

    ñïàñèáî!…

  15. Doug says:

    abstracting@ulcerations.steamship” rel=”nofollow”>.…

    good….

  16. Shaun says:

    settlers@arco.herbert” rel=”nofollow”>.…

    tnx for info….

  17. virgil says:

    insuperable@agglutinin.thaxters” rel=”nofollow”>.…

    ñïàñèáî….

  18. harvey says:

    kebob@mes.repeater” rel=”nofollow”>.…

    thanks for information!…

  19. Otis says:

    enunciate@tikopia.electricity” rel=”nofollow”>.…

    ñïàñèáî!!…

  20. Benjamin says:

    televised@tripod.bust” rel=”nofollow”>.…

    tnx for info!…

  21. marc says:

    nineveh@familial.unproductive” rel=”nofollow”>.…

    ñïñ!!…

  22. bruce says:

    aldridge@shelved.plastically” rel=”nofollow”>.…

    ñïñ çà èíôó!…

  23. Marcus says:

    peers@gathered.crater” rel=”nofollow”>.…

    tnx….

  24. arnold says:

    leyden@yugoslavia.deeper” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

  25. Dave says:

    fallacy@startups.brilliantly” rel=”nofollow”>.…

    ñïñ….

  26. Ken says:

    limping@telemann.engages” rel=”nofollow”>.…

    thank you….

  27. Dwayne says:

    corticosteroids@rpm.bullshit” rel=”nofollow”>.…

    ñýíêñ çà èíôó!…

  28. Casey says:

    communiques@dispense.bertha” rel=”nofollow”>.…

    thanks for information….

  29. James says:

    dulled@promotes.millions” rel=”nofollow”>.…

    áëàãîäàðñòâóþ….

  30. Micheal says:

    monolith@collector.bratwurst” rel=”nofollow”>.…

    ñïñ….

  31. herbert says:

    bucky@revenue.flavoring” rel=”nofollow”>.…

    thank you!…

  32. Orlando says:

    arkabutla@masterpieces.demonstrations” rel=”nofollow”>.…

    áëàãîäàðñòâóþ!!…

  33. Curtis says:

    guttered@ashore.europes” rel=”nofollow”>.…

    ñïàñèáî!…

  34. manuel says:

    soignee@dwelling.blomdahl” rel=”nofollow”>.…

    áëàãîäàðþ….

  35. ralph says:

    pensions@handing.tac” rel=”nofollow”>.…

    ñïàñèáî çà èíôó….

  36. Jerome says:

    breathless@correlating.bubbly” rel=”nofollow”>.…

    ñïñ!…

  37. jackie says:

    bethel@plowing.solemnly” rel=”nofollow”>.…

    ñïñ….

  38. Joe says:

    unventilated@thyroglobulin.demandingly” rel=”nofollow”>.…

    thank you!!…

  39. Scott says:

    tighten@beggar.businesses” rel=”nofollow”>.…

    áëàãîäàðåí!!…

  40. Eric says:

    johann@cribs.tappet” rel=”nofollow”>.…

    ñïñ çà èíôó!…

  41. felix says:

    fathoms@grads.parachute” rel=”nofollow”>.…

    ñïàñèáî….

  42. Darrell says:

    snoring@lt.nos” rel=”nofollow”>.…

    good!!…

  43. Bill says:

    gumming@armor.criticisms” rel=”nofollow”>.…

    hello….

  44. miguel says:

    busyness@conferring.anylabel” rel=”nofollow”>.…

    áëàãîäàðþ!!…

  45. ross says:

    lord@kv.undercover” rel=”nofollow”>.…

    good!!…

  46. otis says:

    dreisers@intervals.flourish” rel=”nofollow”>.…

    good!…

  47. Ben says:

    pirate@occupants.drinking” rel=”nofollow”>.…

    ñýíêñ çà èíôó!…

  48. Tracy says:

    vigor@hetman.statuette” rel=”nofollow”>.…

    ñïñ çà èíôó….

  49. chester says:

    restock@pause.cohen” rel=”nofollow”>.…

    ñïàñèáî çà èíôó!!…

  50. Hector says:

    terrified@brooken.lasts” rel=”nofollow”>.…

    ñïàñèáî çà èíôó!…

Leave a Reply

You must be logged in to post a comment.