Archive for October, 2011

Our Android book, Android in Practice, is here!

I just wanted to reach out quickly and mention that our book Android in Practice (AIP) is finally done, it’s available, and most importantly, it’s good–or at least we like to think so! Let the archer speak for himself:

Android in Practice - Book cover

Android in Practice - Book cover

To get the obvious question out of the way: why another book, and what do we think makes this one different from the many others out there? There’s a strikingly simple answer to that: we believed that back when we started, there were very few books, if at all, that covered Android application development in enough depth, with enough inside knowledge, to satisfy those who (want to) develop Android apps for a living. We wanted to go way beyond the standard Hello World thing, and I believe we achieved that with AIP.

How? First of all, Charlie Collins (now working for MOVL, creators of Poker Fun), Michael Galpin (formerly responsible for the Android app at eBay, now working for Bump Technologies) and I (responsible for the Qype Android app, and large parts of the infrastructure behind it) do exactly that: we build Android apps for a living. We have been working with Android ever since it was in alpha status, when there hadn’t even been actual devices to run the platform. We fell in love with it, and we spent three years since then diving into the platform details, finding problems, solving problems, and where we could, share our findings through blog posts or StackOverflow. Since we were hearing the same questions over and over again, we thought it was about time to pour all this into a more handy format, so here it is: Android in Practice is our take on the developer’s cookbook, containing those recipes–or techniques as we like to call them–we think will help most in making delicious apps, including:

  • A close look at the platform itself, why it’s Java, but why it actually isn’t, why it’s Linux, but why it actually isn’t, what it is comprised of from tools and middleware, to framework classes.
  • Okay, we also have a Hello World part. There, I said it.
  • An in-depth explanation of Android’s life-cycle and task model
  • A comprehensive chapter about UI, where we explain how Android renders views, how to write themes and styles (based on a post from my blog here), how to implement state and 9-patch drawables, how to write scalable UIs, etc.
  • We have an entire chapter on services, covering everything from running services in separate processes, communicating via IPC with other services, how to run process-local services and how to leverage Intents.
  • We also found many people struggle with concurrency on Android, so we added a chapter that focuses entirely on threading, tasking, and asynchronous message dispatching. Yes, AsyncTask is covered here.
  • Storing data is fundamental to many apps, so another chapter focuses entirely on that. From simple preference files to Preference activities to SQLite and ContentProviders, it’s all there.
  • Many apps these days fetch their data not from the device, but from the cloud. That’s why we’ve added a chapter that focuses on networking, HTTP, parsing XML and JSON, and along the way also let you in on a few secrets about how to make your network code rock solid.
  • No Android book could be complete without covering location. Hence, we’ve added a separate chapter focusing solely on best practices for writing location aware applications. The demo app for this chapter lets you find beer breweries near you. Selling argument??
  • We know people  love to use their smartphones to listen to music or watch videos, so multimedia was another big topic for us. In that chapter, we let you in on the details of streaming and recording music and videos in your apps, and how to let other applications retrieve that data from your apps.
  • Gaming is becoming huge on Android, so we felt the book would not be complete without adding a chapter on 2D and 3D drawing. Here we cover OpenGL, and how to render arbitrary shapes and text to a canvas.
  • If you think other books cover all those things as well, then we still have a few aces up our sleeves. Yes, we have a chapter on testing, and another one on build automation. We cover not only the basics like running unit and functional tests on a device, we also cover the thing only the cool kidz use, like Robotium and Robolectric, and yes, even the monkey! We also show you how to manage your builds with Maven and its Android plug-in, and to run your builds from a build server to satisfy all your automation needs.
  • Last but not least, the tablet thing did not simply rush past us. We have an entire chapter on tablet development, and how to use the ActionBar, Fragments, and drag and drop.
  • The appendix is also no slouch, since we have an in-depth coverage of SDK tools like ADB, ProGuard, and Monkeyrunner in there, and also touch on various other topics such as StrictMode, alternative languages, and WebView’s Java-to-JavaScript bridging capabilities.
Oh and did I mention we have sample apps for practically all of that? After all, it’s an “in practice” book. We have decided to put QR-codes in the book, so you can simply whip out your Android phone, scan the barcode while reading, and see the code being discussed in action! Just look for something like this:
So, if you feel like catching up on Android development, the book is currently on sale on Amazon! Or alternatively order directly on manning.com and get both the print and ebook editions. Oh right, a Kindle version will be available very soon, too.
And in the event you’ve already bought it, please, review us on Amazon. Good or bad, preferably good, but any feedback is appreciated. You can also drop by the author forum and leave us feedback there. We will consider all feedback for upcoming revisions of the book.
Thanks everyone and we hope you enjoy Android in Practice!


Book Review (Book 5) – The Cloud of Unknowing

This is a continuation of the books I challenged myself to read to help my career - one a month, for year. You can read my first book review here. The book I chose for October 2011 was: The Cloud of Unknowing, Anonymous: The role of faith in life. Once again, this is out of order, but the book came in from a hold at the library so I’ll do this one now.

Why I chose this Book:

This book is probably the most far afield for many of my readers – some folks don’t hold a faith, others have faiths that are different from mine. That’s fine – I think this is still an intriguing read.

However this is a religious work – if you’re not into that sort of thing, it’s completely OK. As I’ve mentioned early-on, a book list for your career can include many kinds of books. Faith is such a part of my life that I find it impossible to separate from my day-to-day efforts. To that end, a little about this book is in order.

The book was written in the 14th century by an unknown, anonymous author, probably a Carthusian monk in Europe. It’s a work involving the deep thoughts around the intersection of intellection over contemplation. Contemplation is what ancient Catholics called meditation, or focus. It’s a really deep work involving philosophical history, specifically in the Christian tradition. Even as old and philosophical as it is, many contemporary writers, singers (Like Leonard Cohen) and others have referenced it, used it words, or developed entire works around it.

What I learned:

So what did I learn? Actually quite a bit, specifically on the role in contemplation in life. As a technologist, I tend to stay incredibly busy and the temptation is always to be very scattered. But lack of focus is often the enemy of getting things done correctly. Focusing on what really matters and being in the moment is a powerful tool in professional life. It has taught me that now, more than ever, I need to decide what I will not give a lot

As I mentioned, this is a religious work – it has far more value to me there than in the pure business sense, although I find those two linked irrevocably. The way I treat others in both personal and business relationships is my character – which I strive to improve every day.

I highly recommend you read something that is internal like this in your career development. Money, success and fame are not all that there is – and those things are not separated from who you are as a person.


No more conditional comments in IE10

It’s not exactly news – it was announced in July in HTML5 Parsing in IE10 – but in case you missed it, Microsoft are removing support for conditional comments from IE10.

I don't expect this to be a big deal. Actually I’m not sure it will have any impact at all, at least not for me. It’s already a rare thing to need to do something special for IE9.

Read full post

Posted in .

Copyright © Roger Johansson



Using Windows Azure Regions efficiently

Moving your application to the cloud might not be easy as it sounds. The typical sample we always see in documentation or demos about an ASP.NET application created from the Visual Studio template and deploy it in Azure as a package is definitely very far from reality. There are multiple factors that can affect the response time and availability of your applications in the cloud but you can not easily see until you embark on a real project. Application distribution and deployment is one of those factors, and the one we are going to discuss in this post.

Windows Azure uses the idea of regions to manage the physical distribution of your applications and data. A region in a nutshell represents a Microsoft data center where you can deploy your application or part of it. Nowadays, you can find multiple regions spread across the globe in places such as North America, Europe and Asia.

There is another abstraction layer on top of regions called "Affinity Groups", which simply tells the Fabric controller to do its best to ensure groups of related services are deployed in close proximity whenever possible to ensure optimization for inter-app communication. For example, in a typical web application with a database,  you will want to deploy the web application as close as possible to the database server. 

Finally, another important concept you need to understand in this deployment model is the idea of “hosted service”. A hosted service basically represents an unit of deployment associated to a public DNS in the cloud. You deploy your applications in a hosted service, which is also tied to a region or affinity group. What Azure gives you is a public address for reaching that hosted service in the cloud, which is “[you app name].cloudapp.net” for applications hosted in the production environment and an auto generated guid for applications hosted in the staging environment. You can also think in a hosted service as a load balancer that forwards requests from that public address to one of the instances or VMs associated to it.

Let’s discuss the aspects you need to consider for selecting the right regions for deploying your application.

  • Network latency: reducing the network latency is very important as it will impact directly on the response time for your applications. You will want to have your users as close as possible physically from your applications and data. For example, if you have some potential users in the US and Europe, you will want to deploy two exact replicas from your application and data in the US and Europe data centers. As you might guess, this is not as easy as it sounds and there are a lot of challenges you need to address, how you can effectively redirect the users to the right region, or how you can synchronize your data across regions are typical questions or concerns you have to tackle first.
  • Availability: you will want to have your applications available all the time. Many things can happen, but you need to understand that a region or data center might become offline and your application should be prepared to handle that scenario. Your applications and data should be replicated across multiple regions to not be affected when things like this occur.   

Microsoft already offers a set of tools or technologies you can use to address these two aspects, so let’s discuss some of them in detail in the next paragraphs.

Windows Azure Traffic Manager

While this technology is still a CTP and not available for all public in general, it will provide several methods for distributing internet traffic among two or more hosted services in different Windows Azure datacenters. It is in essence a distributed DNS service that knows which Windows Azure Services are sitting behind the traffic manager URL and distributes requests based on different policies  or modes you can configure. It will initially support three modes, “Failover”, “Performance” and “Round-Robin”.

In the “Failover” mode,  all the traffic is redirected to a single hosted service, unless it fails. If the redirection fails because the hosted service is not longer available,  it then directs the traffic to the hosted service configured as failover. For example, you can configure the South Central US region as a backup for the North Central US region and vice versa. If any of those regions go offline, the other one will take its place.

In the “Performance” mode, all traffic is mapped to the hosted service “closest” to the client requesting it.  For example, this will direct users from the US to one of the US datacenters and European users will probably end up in one of the European datacenters.

Finally, in the “Round-robin” mode, the traffic is distributed in a round robin fashion across several hosted services configured in the policy.

As you can see, this tool only tackles the two aspects mentioned before from the point of view of traffic redirection. However, you also need to make sure the data is also consistently available in all the regions, and that’s something this tool won’t solve. For example, if the users are redirected from North US to Central US, you need to make sure the data they get access look the same.

Content Delivery Network (CDN)

You can imagine the Windows Azure Content Delivery Network as a huge http cache spread across the globe for content such as images, files, scripts, or static html to name a few. You can either configure CDN for a blob storage account or an http endpoint in your application (and endpoint with an url ending in “cdn”, for example xxx.cloudapp.net/cdn). All that content will be cached in the nodes that are part of the network using standard Http caching. The CDN will serve later the cached copy closest to the user requesting it, improving in this way the response time.

There are today more than 18 locations or nodes globally (United States, Europe, Asia, Australia and South America) and this number keeps growing.

SQL Azure Data Sync

While the Azure Table Service already provides some built-in support for crash recovery based on the idea of partitions that are replicated across different nodes (in different sub regions, for example North US and Central US), a SQL Azure database is not prepared for that scenario.  If you also use something like the Traffic Manager to redirect users to the closest data center, you probably would want to have all the databases in the different regions in sync between them making all this process transparent to the user.

If you want to support that scenario, the SQL Azure Data Sync is the tool that will help you in this matter. In a nutshell, SQL Azure Data Sync is a cloud-based data synchronization service built on the Microsoft Sync Framework technologies. It provides bi-directional data synchronization and data management capabilities allowing data to be easily shared across SQL Azure databases within multiple data centers.

There are a few things you will have to configure in this tool

  • The databases you want to keep in sync, and also the tables and columns in those databases
  • The schedule or frequency for doing the synchronization.
  • How you want to resolve any conflict that might occur during the synchronization.

As you can see, the combination of this tool with the traffic manager will help you to keep applications and data in sync between different region for the most common scenarios.


A different take on Star Wars

If you’ve ever seen any of my presentations lately, I’ve been using these lovely Star Wars-inspired pictures to emphasize a point or just for plainly visually improving my slides. Today I’d like to tell you a little more about the pictures and the person behind them.

A few months ago, a close friend of mine made me aware of Kristina Alexanderson‘s wonderful Star Wars-based photo collection CClone 365-2011. What she does is taking Star Wars figures and putting them in everyday contexts, creating wonderful, touching and beautiful situations!

Kristina is also a big fan and partaker of Creative Commons and sharing, and works with helping students becoming more aware of Internet and its possibilities in the project Webbstjärnan, and anyone with such good values deserves the attention!

Now, feast your eyes!

I'm afraid of the droids we're looking for

Can you clone this?

Beam me up, please...

Out fishing for droids? (alternative version)

The Stormtrooper beauty

Homesickness

We are going towards the light


  • Sponsored Links

  • October 2011
    M T W T F S S
    « Sep   Nov »
     12
    3456789
    10111213141516
    17181920212223
    24252627282930
    31  
  • .

    Copyright © 1996-2010 Answer My Query. All rights reserved.
    iDream theme by Templates Next | Powered by WordPress