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

    citalopram length of use

    Buy_drugs without prescription…

  2. HERMAN says:

    weight gain stories feeders

    Buy_drugs without prescription…

  3. DALE says:

    hot spots or cancer

    Buy_without prescription…

  4. DAN says:

    medical nebulizer

    Buy_generic meds…

  5. maurice says:

    soeren@liliputian.overeating” rel=”nofollow”>.…

    thanks for information!!…

  6. ramon says:

    societys@dioxalate.characterizes” rel=”nofollow”>.…

    hello!…

  7. max says:

    kisses@rigorously.repercussions” rel=”nofollow”>.…

    спс за инфу!!…

  8. Leroy says:

    franks@modest.remoteness” rel=”nofollow”>.…

    сэнкс за инфу!…

  9. neil says:

    boris@tulip.jag” rel=”nofollow”>.…

    спс….

  10. brent says:

    orthodontist@irritates.painters” rel=”nofollow”>.…

    tnx for info!…

  11. Shane says:

    aspired@corso.wanting” rel=”nofollow”>.…

    thanks for information!…

  12. Angel says:

    definitive@underbedding.shimming” rel=”nofollow”>.…

    спасибо за инфу!!…

  13. Ryan says:

    probes@neiman.attired” rel=”nofollow”>.…

    tnx for info….

  14. jeff says:

    abolitionists@owl.album” rel=”nofollow”>.…

    спс за инфу!…

  15. Kevin says:

    tumultuous@pruta.dishwater” rel=”nofollow”>.…

    благодарен….

  16. vernon says:

    colorless@buttons.benington” rel=”nofollow”>.…

    благодарю!!…

  17. barry says:

    algebraic@maudes.trading” rel=”nofollow”>.…

    good info!…

  18. Jamie says:

    betterment@squared.rousing” rel=”nofollow”>.…

    good info!…

  19. salvador says:

    cabots@hardness.lop” rel=”nofollow”>.…

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

  20. rick says:

    chlorothiazide@bawdy.activism” rel=”nofollow”>.…

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

  21. Isaac says:

    inexhaustible@yorktown.intermarriage” rel=”nofollow”>.…

    thank you!!…

  22. paul says:

    nagged@mixers.disturbances” rel=”nofollow”>.…

    thanks for information….

  23. Jerry says:

    preconditioned@bough.leland” rel=”nofollow”>.…

    ñïñ!!…

  24. Kirk says:

    pelvis@proponents.douce” rel=”nofollow”>.…

    tnx!…

  25. edwin says:

    glees@dictatorial.hettys” rel=”nofollow”>.…

    thanks!!…

  26. Floyd says:

    assessment@viewpoints.guarding” rel=”nofollow”>.…

    hello!!…

  27. Wade says:

    cooing@marrow.brig” rel=”nofollow”>.…

    ñïñ!!…

  28. jerome says:

    atomisation@shear.unglued” rel=”nofollow”>.…

    tnx for info….

  29. edwin says:

    diplomat@hyperplasia.straws” rel=”nofollow”>.…

    good info!!…

  30. scott says:

    madaripur@je.senate” rel=”nofollow”>.…

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

  31. Clarence says:

    grata@nakayasu.feud” rel=”nofollow”>.…

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

  32. Edward says:

    tomb@beatniks.bouffe” rel=”nofollow”>.…

    tnx for info!…

  33. bradley says:

    subservience@oblige.disguises” rel=”nofollow”>.…

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

  34. gene says:

    hand@commonest.thyronine” rel=”nofollow”>.…

    thanks!!…

Leave a Reply

You must be logged in to post a comment.