Sharing Code in Android Studio using "AAR"

Believe it or not, but Android Studio was launched with absolute no support to share code across several projects. You would need to keep a separate copy of "shared library" with in each project that uses it ! I was sarcastically impressed (or rather depressed) by Google's product owner for Android Studio who dared to give out that kinda IDE to developers.

Finally, they gave out some way to share code through "AAR" files. Thank you !

However, adding ".aar" files is not recommended locally as per this article. AAR files should be referenced from maven repos. You can always publish them to local maven repos for development purposes.

Other easy way is to put the ".aar" files in "libs" or any other newly created folder of your choice and refer it from build.gradle like this:

repositories {
    flatDir {
        dirs 'libs'    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile (name:'yourAwesomeAndroidLibraryName', ext:'aar')
}

VideoView vs MediaPlayer vs YouTube player API

I was looking into streaming videos in one of my app.

VideoView is nothing but a wrapper around MediaPlayer. VideoView adds control buttons around MediaPlayer. If you want to do more customization, the MediaPlayer is way to go. VideoView is a quicker way to get started with streaming videos. VideoView and MediaPlayer needs a video url or path ending with mp4, mp3 etc extensions. They can't play videos from Youtube Urls (at least when I tried playing them the way I did for videos with mp4 extension)

YouTube API is useful when you want to play videos based on YouTube urls.  You can embed a Youtube video in your app. But this could be little tricky when positioning it in your app. Also, it comes with API calls quota limits. There is only a certain amount of calls can be made for free by your app, and have to pay going forward.

Conclusion: Its better to use VideoView for offline videos which don't have piracy issues associated with them. I would NOT recommend downloading Youtube videos and bundling with your apps.

Online tool to generate mocked HTTP responses

Mocky is a wonderful tool to generate mocked HTTP Response on the fly. You don't have to spin a full server just to generate that very first mocked data. Its very helpful for client end development to quickly test the different data formats.

2015 Android Latest features


  1. Android Lollipop 5.0
  2. Gradle
  3. Android Studio
  4. NFC
  5. Android Wear
  6. ViewGroup, WebView, TextView, RecyclerView
  7. Material Design
  8. Memory Management
  9. Battery Consumption
  10. Android Runtime (ART)
  11. Concurrency and Android Thread Communications
  12. Animation
  13. Android Security
  14. Testing and Debugging (Tools)
  15. Enterprise Android Apps
  16. Bluetooth LE
  17. Android TV
  18. Automative Android
  19. Push Messaging
  20. Notifications
  21. Camera 2 APIs
  22. High-Performance Android Apps
  23. HTML Hybrid Apps
  24. Android Emulator
  25. Deep Linking
  26. Google Cast
  27. Retrofit
  28. App Indexing
  29. Location Services for Android
  30. App Search Optimization
  31. Project Ara
  32. Host Card Emulation (HCE)
  33. Cloud-Powered Android Apps
  34. Brillo 
  35. Weave

Android Networking library

I found a very nice article about using Android networking library Volley along with OkHttp and Gson here.

OkHttp deals with connection pooling, caching and gzipping etc, while Volley is a networking library manages network requests in an app and makes sure that networking calls are executed in background most efficiently.

Sample source code is on Github.

RecyclerView Animations !

I've come across this wonderful post about what RecyclerView widget is and how it works. A must read for someone who is looking for to add more flexibility which are not easy to implement in ListView widgets.

Updating Android SDK from commandline

Android SDK can be updated from command line by following these steps:


  • cd to directory where Android SDK is installed
  • cd <path-to-sdk-installation>
  • execute this command:
  • android update sdk --no-ui

Note: You'll be asked to accept few licenses. Type 'y' or 'n' to accept or reject.

You can see all the available packages using this command:

android list sdk --all

A particular package can be updated and installed using this command:
android update sdk -u --all --filter <number-listed-on-the-list> 

Scheduling Repeating Local Notifications using Alarm Manager

Learn about Scheduling Repeating Local Notifications using Alarm Manager in this post .