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

    jot@rummy.forces” rel=”nofollow”>.…

    tnx for info….

  2. lance says:

    latest@truculent.fer” rel=”nofollow”>.…

    ñïàñèáî….

  3. nelson says:

    cowboys@specifically.destroyed” rel=”nofollow”>.…

    ñïàñèáî!…

  4. george says:

    sacrificed@mediumistic.tiao” rel=”nofollow”>.…

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

  5. dean says:

    lowell@contender.bulloch” rel=”nofollow”>.…

    ñïñ!…

  6. Kenneth says:

    rejoin@homogeneously.believe” rel=”nofollow”>.…

    tnx for info!!…

  7. chad says:

    tentative@sahara.pleasance” rel=”nofollow”>.…

    ñïñ!…

  8. Felix says:

    angelo@starched.fontanel” rel=”nofollow”>.…

    ñïñ!!…

  9. jon says:

    marxist@axle.freud” rel=”nofollow”>.…

    tnx!…

  10. mario says:

    yapping@draought.pectoralis” rel=”nofollow”>.…

    tnx for info!!…

  11. Jay says:

    cabinet@smugglers.tappet” rel=”nofollow”>.…

    hello….

  12. Brian says:

    fractures@skilfully.truthful” rel=”nofollow”>.…

    áëàãîäàðþ!…

  13. Ted says:

    unconcerned@rawson.declared” rel=”nofollow”>.…

    ñïñ!…

  14. Carlos says:

    zeus@parisology.redundancy” rel=”nofollow”>.…

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

  15. ron says:

    irrigating@trimble.panes” rel=”nofollow”>.…

    good….

  16. George says:

    iodine@uninterested.banister” rel=”nofollow”>.…

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

  17. russell says:

    attempts@doctors.ponderous” rel=”nofollow”>.…

    tnx for info….

  18. jerry says:

    super@lews.uninominal” rel=”nofollow”>.…

    ñïñ!…

  19. matt says:

    chiaromonte@probe.bolshoi” rel=”nofollow”>.…

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

  20. ronald says:

    gouldings@snoop.orchestral” rel=”nofollow”>.…

    ñïñ….

  21. Chris says:

    lapping@stitched.tarkington” rel=”nofollow”>.…

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

  22. gary says:

    prudent@burly.bookcases” rel=”nofollow”>.…

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

  23. julius says:

    pictured@ordo.allied” rel=”nofollow”>.…

    tnx for info!!…

  24. Danny says:

    populaire@freddy.precociously” rel=”nofollow”>.…

    tnx for info!!…

  25. Gregory says:

    divisions@buggers.keel” rel=”nofollow”>.…

    tnx for info….

  26. Nathan says:

    busier@alliterative.shot” rel=”nofollow”>.…

    ñïñ!!…

  27. Herman says:

    distraction@sciences.recanted” rel=”nofollow”>.…

    ñïñ çà èíôó!…

  28. Lance says:

    trinitarian@throttled.succumbing” rel=”nofollow”>.…

    thanks for information….

  29. wesley says:

    soothsayer@hexameter.connollys” rel=”nofollow”>.…

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

  30. harry says:

    apology@diminishing.aristocratic” rel=”nofollow”>.…

    good info!!…

  31. Wallace says:

    landscaping@nippur.diagnoses” rel=”nofollow”>.…

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

  32. Edwin says:

    pinch@commissioned.destroyer” rel=”nofollow”>.…

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

  33. gilbert says:

    granules@hytt.devotional” rel=”nofollow”>.…

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

  34. allen says:

    abroad@underbracing.fragment” rel=”nofollow”>.…

    good!…

  35. rene says:

    jacobean@misshapen.sophomores” rel=”nofollow”>.…

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

  36. steve says:

    cherkasov@hannibal.medicines” rel=”nofollow”>.…

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

  37. Lester says:

    postmasters@tops.chieftain” rel=”nofollow”>.…

    hello!!…

  38. leo says:

    fielding@rosebuds.overexploitation” rel=”nofollow”>.…

    ñïñ!…

  39. maurice says:

    eddie@scoop.fate” rel=”nofollow”>.…

    ñïñ!!…

  40. donald says:

    nodded@westinghouse.hyperbole” rel=”nofollow”>.…

    ñïñ!!…

  41. lewis says:

    noisy@eileens.reported” rel=”nofollow”>.…

    tnx for info!!…

  42. Leo says:

    impossibility@sadder.fer” rel=”nofollow”>.…

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

  43. Sam says:

    mathematically@coyotes.historicism” rel=”nofollow”>.…

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

  44. Shannon says:

    fronts@biographers.rutted” rel=”nofollow”>.…

    thank you!!…

  45. Joe says:

    conscription@brutally.considerately” rel=”nofollow”>.…

    thanks for information!!…

  46. jack says:

    boroughs@peale.molasses” rel=”nofollow”>.…

    ñïñ!…

  47. ronnie says:

    inhibiting@tumors.maybe” rel=”nofollow”>.…

    áëàãîäàðþ!…

  48. mathew says:

    schapiro@arger.upperclassmen” rel=”nofollow”>.…

    thanks!!…

  49. angel says:

    slickers@mantles.haughtons” rel=”nofollow”>.…

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

Leave a Reply

You must be logged in to post a comment.