Android From The Trenches

I recently was slated to present at Philly Emerging Tech last week. Unfortunately a few things came up and I was not able to make it at the last minute. However, I did record my talk and send it to the Philly Emerging Tech team to distribute to their attendees. They have since uploaded the talk to their Vimeo page for everyone to view. Below is that talk. The talk covers my experience in having two apps in the top 100 free category in Google Play. Enjoy.

ETE 2014 – Donn Felker – Android From The Trenches from Chariot Solutions on Vimeo.

The Best Parent I Ever Knew

This is a detour from the regular business and tech stuff I write about, but its still something I thought most people would enjoy.

This is the story of the best parent I ever knew.  

Having kids is one hell of a journey. The first few hours your newborn comes home is a moment filled with happiness, exhaustion and pure fear. Happiness due to the joy of children, the health of your child and family and the joy of creating life. The exhaustion from birth itself (if you’re the woman of course) and the emotions and the energy exerted during the last couple days is overwhelming yet energetic at the same time. Then eventually … the fear sets in. You begin to think – Ummm I’m not entirely sure I know what I’m doing. I hope I don’t mess this thing up. But then you remember you’re the one who prepared for this. Everything will be fine you tell yourself. Just hang in there, it will be Ok. Well, at least thats what I told myself.

The time has come to put your hard planning to work. You’ve had grandiose plans on how to raise your kid. You’ll do everything it takes to make them the shining example of the golden child every parent aspires to have. You’re positive other parents are going to envy your ability to sooth, redirect and manage your children with the nothing but the twitch of a finger. You know how to handle ALL of the situations that are going to arise. Hell, you read the top 10 best selling Baby, child psychology and parenting books on Amazon.com. You’re already on babycenter.com’s weekly mailing list for progress statistics. You? You’re doing all your research. You’ve got this. You’ve picked out the best organic lavender cucumber massaging tear free non-sulfate shampoo and body wash money could buy. You’ve got the best strollers, car seats and non BPA bottles you could find. You’ve got this baby thing figured out. You are going to rock this parenting gig like nobody else. You’re not sure why your other friends are having problem managing their kids. Maybe they just don’t work as hard as you? Yeah, thats probably it.  Maybe they just don’t care. There must be something wrong with them, right? Sure. Yeah … Right. You got this, right? Well, ya see, thats what I told myself.

Then life kicked in, WITH kids. Reality set in and you realize everything you thought you knew was wrong and you actually don’t know much of anything about raising kids. You end up texting those same friends you thought were inept parents in a plea for help – “OMG, he/she won’t stop crying/whining, I haven’t slept more than 4 hours in 3 days. I’m losing my mind. He/She won’t go to sleep. I need a moment to breath. Please help, what do I do?” Ha!  Welcome to the beginning of parenting. That was me and my wife with our first and we were calling our friends for help.

At that moment I realized …

I was the best parent I ever knew before I had kids. 

Android Jobs

I just launched AndroidJobs.IO, a job marketplace for Android Professionals to find great jobs from top notch companies. Some of the top notch companies publishing jobs on Android Jobs include Pandora, Square and Etsy.

If you’re and Android Professional you can learn about the new featured Android Jobs by either subscribing to the new posting notification email on AndroidJobs.IO or you can sign up for the weekly Android Dev Digest newsletter. As always, you can visit the site AndroidJobs.IO and view the postings there as well.

If you’re looking to hire and Android Professional (Engineer, Designer, Product Manager, etc) you can post a Link listing or a Featured listing. The link listing will show up at the bottom of the page, below the fold, and will be visible for 30 days. The Featured listing will be shown in a highly visible job card posted above the fold at the top of the site for 30 days. The posting will also be actively marketed to the entire Android Dev Digest mailing list that is sent out weekly (Android Jobs sponsors this newsletter). This means that your job posting will be marketed the most targeted audience you can find. Your job will be targeted to Android Professionals every week for four weeks. Your posting will also be posted on Twitter & Google+ and sent to the new job notification email list on a weekly basis.  If you run another job board and would like to have us post your new Android Jobs automatically to our board get in contact with me so we can discuss the integration details.

Enjoy!

PS: A big thank you goes out to John Sheehan from Runscope for inspiration of the site.

Android Bootstrap and Android Studio

Myself and a slew of other folks have been working on getting Android Bootstrap moved over to use Gradle so we can get it working correctly with Android Studio. Also during this process we’re moving the app over to use some of the Google libraries. Changes include:

  • Move from Maven to Gradle*
  • Using AppCompat for the ActionBar
  • Navigation Drawer implementation*
  • Using Picasso to load remote images
  • Reorganize file structure to match Gradle recommendations
  • Various library upgrades

I’m happy to say we’re at an alpha stage with this. If you go to alpha.androidbootstrap.com you can generate a project that has support for all of the items above. You should be able to open the generated project in Android Studio and start coding away.

I also spoke with Jake and a few other people over twitter recently about how it might be a good idea to change the minSdkVersion to 15 when this is released. The reason for this is because if you’re going to create a new project you’re probably going to target v15 or above anyway. Sure, you may miss out on ~30% of the available market (as of Nov 2013), but developing and supporting those old devices (pre v15) for a NEW project just doesn’t make sense most of the time. The maintenance and support costs outweigh the market position you might gain. Plus, if you did support v10+ (or whatever) you’d be losing that market and have a ton of tech debt to manage from that point forward. Why not start with v15? If that becomes the case I’ll probably remove AppCompat and use the built in Android Action Bar.

* The build.gradle is not fully complete yet, we need to implement build variants and a few other things and get the integration tests working. I’m also not happy with how the navigation drawer is implemented  It works, but it is not implemented well. It was simply a port from sliding-menu to the new library to get it work. We will be moving it to a pure fragment based implementation very shortly. 

Loading Remote Images in Android with UrlImageView

As an Android consultant, I find myself needing to load remote images into an ImageView quite often. Doing this with the Picasso library is quite easy as you simply need to tell the library where the image is located and what ImageView to load the image into. At that point everything else is taken care of for you, including caching (thanks Square Engineering team!) This is great! The code to do this looks like this: 

However, I have a problem with this approach. As time progresses you’ll have various different Picasso instantiations all over your code base when you need to load up a new image. This can be easily solved with the Dagger Dependency Injection container and a custom ImageView that I call UrlImageView. This file is shown below:

The UrlImageView.java file is simply an ImageView that has been extended to add a couple of additional methods. The method that we care about in this example is setUrl(). When this method is called, a url is passed into the class and then the injected Picasso instance loads that image located at that URL into into the ImageView (this). During the load, a placeholder is shown. This is the defaultImageId that is a private variable. The placeholder is a drawable file that you use.

Once the file is downloaded, its cached, etc. This depends on how you’ve configured the injected instance of Picasso.

To use this class, simply find the view in your Activity and call setUrl() it as shown below. Everything else is handled for you. :)

So how did I inject Picasso? Easy. With a simple @Provides annotation in our Dagger module as shown below.

Dagger will create the Picasso instance here and each place that I @Inject Picasso this same set up will be used. This has some benefits. Using Dagger I can create different Picasso instances with the @Named attribute (or by extending Picasso). An example of this would be a simple image loader as we’ve done above. The second example would allow me to create a RoundPicasso provider that renders circle images (think Google+ avatars). You would set up Picasso the same as before but you would also call the transform() method and provide a custom implementation of the Transformation interface that renders the image as a circle.

As you can see, its easy to extend an ImageView with very little code to load remote images. I hope this has helped you develop Android applications faster and more effectively.