Google GMS Task vs Bolts Android Task

884 views Asked by At

Facebook has a popular library Bolts which helps in asynchronous processing on Android better. They claim to be better than Android native AsyncTask both in efficiency and code readability. I now see that Google is shipping its own version of Tasks as part of the Google API for Android in the GMS library. They APIs look very similar to Bolts. Has there been any comparison between these two libraries -- in terms of efficiency etc. I have to include GMS for a bunch of other stuff in my app -- so if GMS Task is comparable to Bolts Task -- it may be better not to include Bolts and thus decrease the size of the package.

1

There are 1 answers

0
Pedro Loureiro On

I am just speculating here but I think that google basically copied Parse's library and made some small adjustments.

The API is essentially the same.

Most classes have the same name, structure and public methods.

Here are a few differences I noticed:

  • in bolts, when you call task.continueWith(continuation), the default scheduler for the continuation is the scheduler of the original task whereas with google's version it is the main thread scheduler
  • think Google removed the immediate scheduler
  • Google added method overloads where you can pass an activity. The only thing this does is cancelling the task if your activity pauses. I don't think this is great because the developer might expect to have a full-fledge mechanism that will still deliver the result when you return to the activity but that won't happen.

Which one should you use?

If you are using GMS, probably google's.

If you are not using GMS and want to stay away from it (e.g. publishing app outside Play Store devices) use Parse.

I haven't measured or seen anyone measuring it but I think the results will be the same.