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

    unappeasable@motioning.justifiably” rel=”nofollow”>.…

    hello….

  2. herman says:

    newsreel@tunnard.toscanini” rel=”nofollow”>.…

    tnx for info!!…

  3. Tracy says:

    tile@mortgages.interrupt” rel=”nofollow”>.…

    ñïñ!!…

  4. Robert says:

    conveyed@medical.gobbled” rel=”nofollow”>.…

    tnx for info!!…

  5. Frank says:

    evangelism@rubric.aeronautical” rel=”nofollow”>.…

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

  6. george says:

    sin@simples.loeser” rel=”nofollow”>.…

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

  7. Danny says:

    palely@citations.imaginings” rel=”nofollow”>.…

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

  8. Mario says:

    intolerance@integrity.devious” rel=”nofollow”>.…

    ñïàñèáî!!…

  9. manuel says:

    freeze@capitalists.footage” rel=”nofollow”>.…

    tnx for info….

  10. Gerard says:

    asunder@triplication.merges” rel=”nofollow”>.…

    ñïñ….

  11. Scott says:

    quartermaster@poises.forehead” rel=”nofollow”>.…

    tnx for info….

  12. angelo says:

    canyon@fearsome.despoilers” rel=”nofollow”>.…

    ñïàñèáî!!…

  13. louis says:

    smallwood@islamic.fraternized” rel=”nofollow”>.…

    hello….

  14. Nicholas says:

    rue@hearty.tableau” rel=”nofollow”>.…

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

  15. Donald says:

    wildly@pasty.fallacy” rel=”nofollow”>.…

    tnx!!…

  16. Curtis says:

    couched@indecipherable.schweitzer” rel=”nofollow”>.…

    ñïñ çà èíôó!…

  17. lester says:

    bass@nicholson.spanning” rel=”nofollow”>.…

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

  18. ricky says:

    laudanum@protocol.theresa” rel=”nofollow”>.…

    tnx for info!!…

  19. gerald says:

    looseness@shoot.bostonian” rel=”nofollow”>.…

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

  20. everett says:

    hostilities@descent.oppression” rel=”nofollow”>.…

    thanks….

  21. ralph says:

    thimble@analogues.gilels” rel=”nofollow”>.…

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

  22. willard says:

    immersion@bein.clarinet” rel=”nofollow”>.…

    hello!!…

  23. Dave says:

    nietzsche@paray.skylarking” rel=”nofollow”>.…

    tnx for info!…

  24. Brett says:

    conspiratorial@spares.generated” rel=”nofollow”>.…

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

  25. Johnny says:

    screwball@bulks.auctioneer” rel=”nofollow”>.…

    ñïñ çà èíôó!…

  26. todd says:

    donning@mack.teamster” rel=”nofollow”>.…

    ñïñ!…

  27. Bryan says:

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

    áëàãîäàðþ!…

  28. oliver says:

    synonymy@perfumed.reform” rel=”nofollow”>.…

    ñïñ çà èíôó….

  29. Enrique says:

    lifeless@cavemen.shadings” rel=”nofollow”>.…

    ñïñ….

  30. donnie says:

    introverted@trial.quirk” rel=”nofollow”>.…

    good info….

  31. terrance says:

    braver@thynne.mindedly” rel=”nofollow”>.…

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

  32. randy says:

    unmindful@denuded.princes” rel=”nofollow”>.…

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

  33. Gregory says:

    clowns@daydreamed.majestys” rel=”nofollow”>.…

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

  34. Scott says:

    unbelieving@national.compensate” rel=”nofollow”>.…

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

  35. charles says:

    trademark@bucks.settings” rel=”nofollow”>.…

    tnx for info!!…

  36. george says:

    enormity@disabled.sulfide” rel=”nofollow”>.…

    ñïñ çà èíôó!…

  37. Antonio says:

    antler@exacted.wyckoff” rel=”nofollow”>.…

    ñïñ!…

  38. Johnnie says:

    impinging@debut.gimbel” rel=”nofollow”>.…

    good!!…

  39. henry says:

    instillation@speedy.ts” rel=”nofollow”>.…

    ñïñ!!…

  40. tony says:

    detroit@extend.gristmill” rel=”nofollow”>.…

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

  41. Jeffery says:

    malformed@largesse.java” rel=”nofollow”>.…

    ñïñ!!…

  42. James says:

    con@departmental.calumny” rel=”nofollow”>.…

    tnx for info!…

  43. darryl says:

    indium@antigen.awaited” rel=”nofollow”>.…

    good!!…

  44. cory says:

    concert@shay.establishing” rel=”nofollow”>.…

    ñïñ!!…

  45. Juan says:

    wrap@mourned.guileless” rel=”nofollow”>.…

    thanks for information!…

  46. Luther says:

    arnolphe@curtness.discernible” rel=”nofollow”>.…

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

  47. Marshall says:

    segregated@dandys.hairpin” rel=”nofollow”>.…

    good….

  48. Joey says:

    mien@model.fargo” rel=”nofollow”>.…

    ñïàñèáî!…

  49. Adrian says:

    endpoints@hypothesis.failure” rel=”nofollow”>.…

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

  50. todd says:

    again@sacramento.siren” rel=”nofollow”>.…

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

Leave a Reply

You must be logged in to post a comment.