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. The Phantom Raspberry Blower says:

    That has to be just about the ugliest piece of code I’ve ever seen in the Java world. Not to mention its inherent poor performance. I guess one will only call this once if coding properly, but it stinks.

  2. rspence says:

    Thanks for posting ..

    Not sure it is that bad … kind of familiar to me from the j2me world. The big deal will be if this kind of fragmentation appears between manufacturers of android devices. When I have to do a work around like this for an issue between a sony and a HTC then we really are in trouble. ;-)

  3. Social comments and analytics for this post…

    This post was mentioned on Twitter by spugamola: Here is some real Android fragmentation I found in the wild – blog post http://bit.ly/7Iip5f #android #crikey #lordylorks…

  4. KENNETH says:


    Pillspot.org. Canadian Health&Care.No prescription online pharmacy.Best quality drugs.Special Internet Prices. High quality drugs. Order pills online

    Buy:Prevacid.Lumigan.Valtrex.Nexium.100% Pure Okinawan Coral Calcium.Actos.Mega Hoodia.Zovirax.Human Growth Hormone.Zyban.Synthroid.Accutane.Petcam (Metacam) Oral Suspension.Prednisolone.Arimidex.Retin-A….

  5. EDWARD says:


    MedicamentSpot.com. Canadian Health&Care.No prescription online pharmacy.Special Internet Prices.Best quality drugs. No prescription pills. Order pills online

    Buy:Lasix.Ventolin.Seroquel.Aricept.Nymphomax.Prozac.Lipitor.Buspar.Wellbutrin SR.Cozaar.Zocor.Advair.Lipothin.Female Pink Viagra.Benicar.Amoxicillin.SleepWell.Zetia.Acomplia.Female Cialis….

  6. JAY says:


    CheapTabletsOnline.com. Canadian Health&Care.Best quality drugs.Special Internet Prices.No prescription online pharmacy. No prescription pills. Order drugs online

    Buy:Seroquel.Lipothin.Wellbutrin SR.Female Pink Viagra.Amoxicillin.Cozaar.Nymphomax.Prozac.Lipitor.Lasix.Zocor.Zetia.Advair.Aricept.Ventolin.Benicar.Acomplia.SleepWell.Female Cialis.Buspar….

  7. KARL says:


    CheapTabletsOnline.Com. Canadian Health&Care.Special Internet Prices.No prescription online pharmacy.Best quality drugs. No prescription drugs. Buy drugs online

    Buy:Prednisolone.Valtrex.100% Pure Okinawan Coral Calcium.Prevacid.Synthroid.Lumigan.Accutane.Zovirax.Zyban.Nexium.Arimidex.Petcam (Metacam) Oral Suspension.Retin-A.Human Growth Hormone.Actos.Mega Hoodia….

  8. CLINTON says:

    ████████►BUY LEVITRA◀███████…

    ▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲▲…

  9. TODD says:

    buy pure acai berry

    Buyno prescription…

  10. JIMMIE says:

    Actos@official.site” rel=”nofollow”>..

    Buywithout prescription…

  11. DARRELL says:

    altace@medication.now” rel=”nofollow”>…

    Buygeneric meds…

  12. RAYMOND says:

    Cozaar@official.site” rel=”nofollow”>..

    Buynow it…

  13. CARLTON says:

    abilify@vs.risperidone.dosage” rel=”nofollow”>.

    Buygeneric drugs…

  14. KIRK says:

    buy@viagra.in.london.england” rel=”nofollow”>…

    Buygeneric drugs…

  15. ALVIN says:

    < a href="http://my.gardenguides.com/members/buy-Tramadol? buy@Tramadol.now

    Buyno prescription…

  16. DARRYL says:

    depakote@parkinsonism.now” rel=”nofollow”>.

    Buyit now…

  17. JESSE says:

    is@sun.pharmaceuticals.depakote.good.quality” rel=”nofollow”>.

    Buyno prescription…

  18. TRACY says:

    side@effects.of.zyrtec.overdose” rel=”nofollow”>.

    Buygeneric meds…

  19. KEITH says:

    Voltaren

    Buygeneric drugs…

  20. COREY says:

    diovan

    Buyit now…

  21. REX says:

    Zoloft

    Buygeneric drugs…

  22. SAM says:

    Yaz

    Buywithout prescription…

  23. MAURICE says:

    asperger zoloft 100

    Buydrugs without prescription…

  24. EDWARD says:

    Yaz

    Buywithout prescription…

  25. RONNIE says:

    leg swelling lasix

    Buyno prescription…

  26. DONNIE says:

    yaz plan b

    Buydrugs without prescription…

  27. AUSTIN says:

    risperdal and luvox loss of libido

    Buydrugs without prescription…

  28. CLINTON says:

    Purim

    Buyno prescription…

  29. CLINTON says:

    Purim

    Buyit now…

  30. DANIEL says:

    Purim@Purim.Purim” rel=”nofollow”>…

    Buyno prescription…

  31. EDDIE says:

    Synthroid@Synthroid.Synthroid” rel=”nofollow”>..

    Buynow it…

  32. VIRGIL says:

    Pain@Balm.now” rel=”nofollow”>..

    Buynow…

  33. MANUEL says:

    Slimfast@Slimfast.Slimfast” rel=”nofollow”>..

    Buygeneric drugs…

  34. ROGER says:

    Purim@Purim.Purim” rel=”nofollow”>..

    Buywithout prescription…

  35. LOUIS says:

    Synthroid@Synthroid.Synthroid” rel=”nofollow”>.

    Buyit now…

  36. TREVOR says:

    Prozac@Prozac.Prozac” rel=”nofollow”>.

    Buygeneric drugs…

  37. DANNY says:

    Prozac@Prozac.Prozac” rel=”nofollow”>…

    Buyno prescription…

  38. MELVIN says:

    ..

    Buywithout prescription…

  39. CHRIS says:

    pyrantel@pamoate.to.kill.acanthocephala” rel=”nofollow”>..

    Buygeneric drugs…

  40. SHAUN says:

    Buygeneric meds…

  41. RODNEY says:

    Buygeneric drugs…

  42. SHAUN says:

    what@side.effects.does.abilify.cause” rel=”nofollow”>…

    Buygeneric meds…

  43. NICK says:

    when@will.i.ovulate.after.using.clomid” rel=”nofollow”>.

    Buyno prescription…

  44. JIMMIE says:

    .

    Buyit now…

  45. SCOTT says:

    cymbalta@20.mg” rel=”nofollow”>…

    Buygeneric drugs…

Leave a Reply

You must be logged in to post a comment.