Oct 18, 2014

Android 5.0 Lollipop API Change

src: http://www.android.com/new/images/banners/lollipop-1600.png
Android 5.0 Lollipop Features

  • Material design
  • Performance focus
  • Notifications
  • Your apps on the big screen - TV
  • Document-centric apps
  • Advanced connectivity
  • High-performance graphics
  • More Powerful Audio
  • Enhanced Camera & Video
  • Screen capturing and sharing
  • New types of sensors
  • Chromium WebView
  • Accessibility & Input
  • Tools for building battery-efficient apps

Classes and Interfaces1473600507

The overall difference between API Levels 20 and 21 is approximately 6.51%.

Android L Preview API Changes

Classes and Interfaces872320319
The overall difference between API Levels 20 and L-preview is approximately 3.77%.

Jul 5, 2014

Migrating Web Site to AWS Cloud - A Quick Guide

This is a quick tip to migrate your existing website to AWS Cloud. I assume that you have basic knowledge of AWS Cloud and server side architecture.  This post does not include a discussion of pros and cons of AWS or Cloud services.  Elasticity and Auto-Scaling are two main features of Cloud.  If we don't leverage these feature then there isn't any difference between hosting website in dedicate server or AWS Cloud. You can create EC2 instance and deploy your existing code. It will work perfect, but in this case you cannot apply auto-scale. There is no purpose of migrating web site to AWS Cloud without auto-scaling.

AWS Cloud Service: Following list has description of essential AWS Cloud service.

  1. EC2 (Elastic Compute Cloud)  - It supports operating systems that includes numerous Linux distributions, and Microsoft Windows Server. Amazon EC2 enables you to increase or decrease capacity within minutes, not hours or day.
  2. RDS (Relational Database Service) - Amazon RDS gives you access to the capabilities of a familiar MySql, Oracle, Microsoft SQL Server, or PostgreSql database engine.
  3. S3 (Simple Storage Service) - Amazon S3 provides a highly durable and available store for a variety of content, ranging from web applications to media files.
  4. CloudFront - CloudFront is content delivery network. It can be used to deliver your entire website, including dynamic, static, streaming, and interactive content using a global network of edge locations.
  5. ELB (Elastic Load Balancer) - Elastic Load Balancing automatically distributes incoming application traffic across multiple Amazon EC2 instances.
  6. Auto-Scaling - Auto Scaling allows you to scale your Amazon EC2 capacity up or down automatically according to conditions you define. Mainly It's based on incoming traffic or CPU utilization.
  7. Route 53 (DNS Service) - Amazon Route 53 is a highly available and scalable Domain Name System (DNS)

Architecture:  Let's assume two different architecture, one deployed on dedicated server and another deployed in AWS Cloud. website developed in PHP/ASP/Java with MySql as backend.

Dedicated Server Architecture : This architecture has mainly three components load balancer, application servers and database.

AWS Cloud Architecture: This architecture has Route 53, ELB, EC2, CloudFront, S3, RDS and Auto-Scaling services used.

Migration Phases
  1. Planning – It will include  financial assessment (TOC/ROI), technical assessment, prototype creation or proof of concept, data migration planning and  application migration planning.  
  2. Execution – It will have execution of planning, modification of application source code and testing.
  3. Deployment – It will have deploy application and data migration, AWS Cloud has various tools like AWS Elastic Beanstalk, AWS CloudFormation, AWS OpsWorks, etc.. for deployment and management.
  4. Monitor – AWS Cloud has AWS CloudTrail and Amazon CloudWatch services for monitor AWS resources.

Tips for the developers:  Migrating to AWS Cloud require code and structure changes.  

  1. Migrate MySQL database to RDS,  MySql database can directly migrate (export - import)  to RDS-MySql engine. 
  2. As you are migrating to AWS Cloud, you have more storage options like SimpleDB and DynemoDB.  You can take advantage of these storage services to off load data from MySql . It’s call hybrid approach  - SQL and NOSQL
  3. In dedicated architecture all files, (for eg:- images, videos, etc...)are stored in web space /some folder in server.  In case of AWS Cloud all files (images, videos, etc  ...) should be stored on S3.
  4. In dedicated architecture, all web assets (CSS, JS, Icons, and Images) are stored in virtual directory of web server and web server or application will serve these assets, which is unnecessary on servers.  In AWS Cloud, all web assets (CSS, JS, Icons, and Images) should be stored in S3 and link with CloudFront.
  5. In dedicated architecture, your cron jobs will run on same web server. In case of AWS Cloud, you may require dedicated EC2 instance for cron jobs or you can create schedule EC2 instance.
  6. In dedicate architecture, you may have only application which serves all request. For AWS you can use two separate servers, Web Server (i.e. Apache HTTP Server, Nginx Server, etc...) and Application Server (Tomcat, IIS, etc...)
  7. Few application services are available in AWS Cloud that you can use depending upon the requirement.
    1. Amazon SQS – Amazon Simple Queue Service (SQS) is a fast, reliable, scalable, fully managed message queuing service.
    2. Amazon SNS - Amazon Simple Notification Service is a fast, flexible, fully managed push messaging service.  It also supports push notifications to Apple, Google, Fire OS, and Windows devices.
    3. Amazon SES - Amazon Simple Email Service is a cost-effective outbound-only email-sending service.


  1. http://aws.amazon.com/whitepapers/migrating-your-existing-applications-to-the-aws-cloud-with-3-example-scenarios/
  2. http://highscalability.com/blog/2010/12/21/sql-nosql-yes.html
  3. http://aws.amazon.com/products/

Jun 27, 2014

Android L Preview API Changes

src: http://developer.android.com/preview/images/l-dev-prev.png

Android L Preview Features

  1. A New Design - Material Design
  2. A New Runtime - ART (Android Runtime)
  3. Enhanced Notifications
  4. Project Volta- Increased Efficiency
  5. Support for OpenGL ES 3.1
  6. Android Extension Pack
  7. Camera API for advanced camera capabilities
  8. Storage - Directory selection
  9. Multiple network connections
  10. Bluetooth broadcasting
  11. NFC enhancements
  12. Scheduling jobs
  13. Enterprise - Managed provisioning
  14. Render PDF as bitmap
  15. Testing and accessibility improvements
  16. Easier switching between input languages
Android L Preview API Changes

Classes and Interfaces872320319
The overall difference between API Levels 20 and L-preview is approximately 3.77%.
New Packages
  1. android.app.job
  2. android.bluetooth.le
  3. android.hardware.camera2
  4. android.hardware.camera2.params
  5. android.media.session
  6. android.media.tv
  7. android.service.voice
  8. android.system

Jun 21, 2014

Android Triangle Pager Sliding Tabs

TriangleTabs is extension of PagerSlidingTabStrip

Note: This is not a plug and play library that you can directly import in project and use. Triangle tabs is extension of PagerSlidingTabStrip library. In this article I will explain, how to modify PageSlidingTabStrip library to create Triangle Tabs.
Android Triangle Tabs Video 

Customise PageSlidingTabStrip

Step 1: Import PageSlidingTabStrip library in AndroidStudio.
Step 2: Let add new attribute for Triangle Tabs in attrs.xml (project -> res -> values). This attribute will allow developer to enable / disable triangle tabs.

<attr name="pstsTriangleIndicator" format="boolean"/>
Step 3: We need to modify Java code for Triangle Tabs.Goto source code and Open PagerSlidingTabStrip.java file
Step 4: Declare boolean variable above constructor, for pstsTriangleIndicator attribute.

private boolean triangleIndicator = false;
Step 5: Fatch pstsTriangleIndicator attribute, write following line in constructor

triangleIndicator = a.getBoolean(R.styleable.PagerSlidingTabStrip_pstsTriangleIndicator, triangleIndicator);
Step 6: Now it's time to draw triangle tab, goto onDraw method and add following code.

Original Code

canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
New Code, conditional code for triangle tabs

if (triangleIndicator) {
      Rect r = new Rect();
      int left = (int) lineLeft + (int) (((lineRight - lineLeft) / 2) - (indicatorHeight / 2)) - 20;
      int top = height - indicatorHeight;
      int right = (int) left + indicatorHeight + 30;
      int bottom = height;
      r.set(left, top, right, bottom);
      Path path = getEquilateralTriangle(r);
      canvas.drawPath(path, rectPaint);
else {
      canvas.drawRect(lineLeft, height - indicatorHeight, lineRight, height, rectPaint);
Step 7: This is last step, declare getEquilateralTriangle() function. This function has code for triangle.

public Path getEquilateralTriangle(Rect bounds) {
        Point startPoint = null, p2 = null, p3 = null;
        int width = bounds.right - bounds.left;
        int height = bounds.bottom - bounds.top;

        startPoint = new Point(bounds.left, bounds.bottom);

        p2 = new Point(startPoint.x + width, startPoint.y);
        p3 = new Point(startPoint.x + (width / 2), startPoint.y - height);

        Path path = new Path();
        path.moveTo(startPoint.x, startPoint.y);
        path.lineTo(p2.x, p2.y);
        path.lineTo(p3.x, p3.y);

        return path;


Step 1: Include the customized library as local library project or you can copy PagerSlidingTabStrip.java, attrs.xml and background_tab.xml in respective folders of your main project.
Step 2: Include the PagerSlidingTabStrip widget in your layout. This should usually be placed above the ViewPager it represents. Noticed pstsTriangleIndicator attribute

Step 3: In your onCreate method (or onCreateView for a fragment), bind the widget to the ViewPager.

// Declar variable 
private ViewPager pager;
private PagerSlidingTabStrip pagertab;
private MyPageAdapter pageAdapter;

// Inside onCreate
pager = (ViewPager) findViewById(R.id.activity_main_pager);
pagertab = (PagerSlidingTabStrip) findViewById(R.id.activity_main_pagertabstrip);
List fragments = getFragments();
pageAdapter = new MyPageAdapter(getSupportFragmentManager(), fragments);
Step 4: Compile & Run application

Jun 20, 2014

Microservice Architecture - A Quick Guide

1. What is Architecture (Software)?
Architecture is the fundamental organization of a system embodied in its components (i.e. Web Server, Application Server, Databases,Storage, Communication layer, etc...), their relationships to each other, and to the environment (i.e. deployment environment shared server, dedicated server, cloud deployment, etc..), and the principles guiding its design and evolution.
2. What is microservice architecture ?
Microservice means developing a single, small, meaningful functional feature as single service, each service has it’s own process and communicate with lightweight mechanism, deployed in single or multiple servers.
3. Advantages of microservice architecture ?
  • Each micro service is small and focused on a specific feature / business requirement.
  • Microservice can be developed independently by small team of developers (normally 2 to 5 developers).
  • Microservice is loosely coupled, means services are independent, in terms of development and deployment both.
  • Microservice can be developed using different programming language (Personally I don't suggest to do it).
  • Microservice allows easy and flexible way to integrate automatic deployment with Continuous Integration tools (for e.g: JenkinsHudsonbamboo etc..).
  • The productivity of a new team member will be quick enough.
  • Microservice is easy to understand, modify and maintain for a developer because separation of code,small team and focused work.
  • Microservice allows you to take advantage of emerging and latest technologies (framework, programming language , programming practice, etc.).
  • Microservice has code for business logic only, No mixup with HTML,CSS or other UI component.
  • Microservice is easy to scale based on demand.
  • Microservice can deploy on commodity hardware or low / medium configuration servers.
  • Easy to integrate 3rd party service.
  • Every microservice has it's own storage capability but it depends on the project’s requirement, you can have common database like MySQL or Oracle for all services.
4. Disadvantages of microservice architecture ?
  • Microservice architecture brings a lot of operations overhead.
  • DevOps Skill required (http://en.wikipedia.org/wiki/DevOps).
  • Duplication of Effort.
  • Distributed System is complicated to manage .
  • Default to trace problem because of distributed deployment.
  • Complicated to manage whole products when number of services increases.
5. In which case / requirement microservice architecture best fit ?
When you need to support Desktop, web , mobile, Smart TVs, Wearable, etc... or you don't know in future which kind of devices you need to support.
6. Which products / companies are using Microservie architecture?
Most large scale web sites including Twitter, Netflix, Amazon and eBay have evolved from a monolithic architecture to a microservices architecture.
7. How independent micro services communicate with each other?
It's depend upon requirement, normally developers use HTTP/REST with JSON or Protobuf(Binary protocol) but are free to use any communication protocol.
8. Why is it that everyone are talking about microservices now?
It’s been nearly 15 years since the concept of Service Oriented Architecture really took hold. With the improvement of RESTful web service and JSON as a data interchange format has made it easier than ever to build easily interconnectable services simply and quickly.
9. Presentation
10. Video

11. Picture: Monolithic vs Modular vs Service oriented architecture
  1. http://martinfowler.com/articles/microservices.html
  2. http://microservices.io/patterns/microservices.html
  3. http://www.infoq.com/presentations/Micro-Services
  4. http://yobriefca.se/blog/2013/04/28/micro-service-architecture/
  5. http://www.tomakehurst.com/microservices-and-monoliths-is-there-a-third-way/
  6. http://www.infoq.com/articles/microservices-intro