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. MARK says:

    is@dexamethasone.steroid” rel=”nofollow”>..

    Buyit now…

  2. ANTONIO says:

    aleve@active.ingredient” rel=”nofollow”>.

    Buygeneric meds…

  3. DENNIS says:

    dilantin@hypoglycemia.alcohol” rel=”nofollow”>…

    Buyit now…

  4. MARCUS says:

    aloe@vera.juice” rel=”nofollow”>..

    Buynow it…

  5. WARREN says:

    maximum@dosage.for.pristiq” rel=”nofollow”>…

    Buyit now…

  6. EDWIN says:

    cymbalta@and.elavil.interaction” rel=”nofollow”>.

    Buygeneric pills…

  7. ROBERTO says:

    .

    Buynow…

  8. FRANKLIN says:

    how@long.before.extenze.works” rel=”nofollow”>.

    Buygeneric pills…

  9. KEVIN says:

    prilosec@and.pepcid.and.carafate.for.dog” rel=”nofollow”>.

    Buywithout prescription…

  10. SALVADOR says:

    weitz@and.luxenberg.accutane.settlement” rel=”nofollow”>..

    Buyit now…

  11. ROSS says:

    bachus@and.schanker.accutane” rel=”nofollow”>..

    Buygeneric drugs…

  12. GERALD says:

    aciphex@how.fast.does.it.work” rel=”nofollow”>.

    Buyit now…

  13. CHAD says:

    Buy@Generic.Abilify.Without.Prescription” rel=”nofollow”>…

    Buynow it…

  14. REX says:

    Order@Abilify.Without.Prescription” rel=”nofollow”>..

    Buygeneric drugs…

  15. RICARDO says:

    Buy@Cheap.Acai” rel=”nofollow”>..

    Buydrugs without prescription…

  16. JERRY says:

    Purchase@Coral.Calcium.Online” rel=”nofollow”>.

    Buynow…

  17. FRED says:

    Get@Coral.Calcium.Online” rel=”nofollow”>..

    Buydrugs without prescription…

  18. STUART says:

    Order@Cheap.Abana” rel=”nofollow”>…

    Buynow…

  19. CRAIG says:

    Order@Cheap.Abana” rel=”nofollow”>…

    Buynow…

  20. ALEX says:

    Order@Generic.Abilify” rel=”nofollow”>.

    Buyit now…

  21. STANLEY says:

    Order@Coral.Calcium.Online” rel=”nofollow”>..

    Buygeneric drugs…

  22. EDGAR says:

    Buy@Acai.Online” rel=”nofollow”>.

    Buynow it…

  23. JEFFREY says:

    Purchase@Acai.Online” rel=”nofollow”>…

    Buynow it…

  24. DONALD says:

    Purchase@Cheap.Acai” rel=”nofollow”>…

    Buyit now…

  25. WALLACE says:

    Purchase@Cheap.Acai” rel=”nofollow”>…

    Buygeneric drugs…

  26. RUSSELL says:

    Purchase@Cheap.Acai” rel=”nofollow”>..

    Buywithout prescription…

  27. DARYL says:

    Buy@Cheap.Energy.Boost” rel=”nofollow”>.…

    Buyit now…

  28. SAM says:

    Purchase@Accutane.Online” rel=”nofollow”>.…

    Buynow it…

  29. TED says:

    Cheap@Generic.Accutane.10mg.20mg” rel=”nofollow”>.…

    Buyno prescription…

  30. ANGELO says:

    Cheap@Aciphex.Online” rel=”nofollow”>.…

    Buynow it…

  31. RUBEN says:

    Order@Acomplia.Online” rel=”nofollow”>.…

    Buygeneric meds…

  32. BOB says:

    Order@Discount.Acomplia” rel=”nofollow”>.…

    Buygeneric drugs…

  33. LOUIS says:

    Purchase@Acomplia.Online” rel=”nofollow”>.…

    Buygeneric drugs…

  34. MARION says:

    Purchase@Cheap.Actos” rel=”nofollow”>.

    Buywithout prescription skx…

  35. RYAN says:

    Purchase@Actos.Without.Prescription” rel=”nofollow”>.

    Buygeneric meds guc…

  36. DUANE says:

    Buy@Discount.Adalat” rel=”nofollow”>…

    Buygeneric drugs sbj…

  37. ARTHUR says:

    Cheap@Abana.Online” rel=”nofollow”>..

    Buyit now zvc…

  38. BRUCE says:

    Get@Acai.Online” rel=”nofollow”>…

    Buynow it zdg…

  39. LEWIS says:

    Purchase@Cheap.Aciphex” rel=”nofollow”>.

    Buygeneric drugs axm…

  40. VINCENT says:

    Purchase@Aciphex.Without.Prescription” rel=”nofollow”>.

    Buydrugs without prescription xab…

  41. NORMAN says:

    Cheap@Aciphex.20mg” rel=”nofollow”>.

    Buyit now ojb…

  42. BRETT says:

    Buy@Generic.Aciphex.20mg” rel=”nofollow”>…

    Buydrugs without prescription jlg…

  43. RANDY says:

    Purchase@Discount.Acomplia” rel=”nofollow”>…

    Buydrugs without prescription ttp…

  44. NEIL says:

    Purchase@Discount.Acomplia” rel=”nofollow”>.

    Buydrugs without prescription tdg…

  45. NICK says:

    Buy@Discount.Actonel” rel=”nofollow”>..

    Buyno prescription lka…

  46. NICHOLAS says:

    Purchase@Cheap.Advair” rel=”nofollow”>.

    Buygeneric pills oir…

  47. SHANE says:

    Get@Advair.Online” rel=”nofollow”>.

    Buygeneric drugs hwi…

  48. AARON says:

    Buy@Generic.Advair.Without.Prescription” rel=”nofollow”>..

    Buyno prescription jwi…

  49. KIRK says:

    acomplia@sleep.apnea” rel=”nofollow”>.

    Buygeneric drugs…

  50. AUSTIN says:

    actos@side.effects.edema” rel=”nofollow”>..

    Buygeneric drugs…

Leave a Reply

You must be logged in to post a comment.