Thursday, 14 February 2013

Working with GIT - The Basics

The most popular version control systems is GIT and with popularity of github, it is the most commonly used!
This post gives a the basics of GIT use - pulling, adding, pushing into the repository!

  1. GIT ToolsYou can play around with GIT using the popular GIT Bash for windows or directly from Eclipse
    a) GIT Bash - This gives a UNIX type of feel and hence is most popular amongst developers. In order to download this, go to -
    b) Eclipse - When in a project which is attached to a GIT repository, right click on it. You will find a tab called "Team". Within this tab, all the GIT related options can be found.

    The options are discussed briefly below - (a) will contain GIT Bash related options and (b) will be the respective eclipse version of the same
  2. Pull - This is needed to get the project in the same state as the master
    a) GIT Bash - git pull b) Eclipse - Under the "Team" option you will find Pull, that does the same thing
  3. Add - This is required to add all the files you have changed into your local Project. Adding these files wont reflect into the main branch. In order to do so, you need to commit your files and then push them into the master branch.
    a) GIT Bash - i.  git add <file 1> <file 2> ... <file n>
                          ii. git commit -m "My Comment"
                         iii. git push
    b) Eclipse - Under the "Team" option, you need to take the following steps
                          i.  Add to Index - This will open a GUI of all the modified files. Select and add them.
                         ii. Commit - Click this and add a comment for this commit
                        iii. Push - Click this to push all these files to the master branch.
  4. Pull With Modified Files - In case you have modified files in your project and you dont want to commit these to the main branch but you want to pull the changes other team members made to the master branch then use the following commands -
    a) GIT Bash - i.   git stash                      ii.  git pull                      iii. git stash pop

Hope this helps. In case of more information - you know where to go - Google !

Wednesday, 5 December 2012

String To Resource ID

Wow, this is one hell of a delayed post ! But nevertheless ... 

A lot of times, when we try to templatize / automate a product, we face the problem of converting a string to its corresponding resource id. For example, a simple input from the user for the drawable name that he/she would want to select for a button. This input will essentially be in the format of a string. Now to map this string to the corresponding drawable id is the task we propose the following solution -

public static int getResId(String variableName, Context context, Class<?> c) {

    try {
        Field idField = c.getDeclaredField(variableName);
        return idField.getInt(idField);
    } catch (Exception e) {
        return -1;

The usage will be -

getResId("icon", context, Drawable.class);

Thats all for now folks !

Wednesday, 27 June 2012

ANDROID - Sound & Shiver

There are these few times when you really wanna give the app some cool features which can be as simple as putting some sounds on button clicks ! This is by far the easiest way to do so -

 public void onClick(View v) {
  MediaPlayer mp = MediaPlayer.create(TestSonido.this, R.raw.sound);  

where R.raw.sound => sound.mp3 in the directory - res/raw

Now as for shivers, if you want to make the phone vibrate on simple clicks do this -
In onCreate 
Vibrator vibe = (Vibrator) context.getSystemService(Context.VIBRATOR_SERVICE) ;

Then in the OnClickListener of your button:
vibe.vibrate(50); // 50 is time in ms

And dont forget you need to add the permission to the manifest (after the </application> tag):
<uses-permission android:name="android.permission.VIBRATE" />

Monday, 25 June 2012

ANDROID & iOS - Commonalities

A very important part of any new idea is the level of discussions you have with people who understand the business. Similar in this case, a very good friend who has recently launched his own startup in US - AIRGRAM gave a very useful insight on mobile app development.

This friend started with the Android version of their product, and within the next few days of their Android launch, they were able to launch the iOS version of it! This came as a surprise since as of today there exists no convertor that does this and to start an app from scratch on any platform does take time!

Hence the revealations - a very concise solution to a major problem !

They designed the most of their app on HTML and used webviews all across the app, hence were able to re-use maximum effort !

Sunday, 24 June 2012

ANDROID - Swipe Gesture

For most of us newbees, we all know how to simply decorate the xmls but man when it comes to slight animation, we are screwed quite literally ! The latest problem we faced was related to the swipe gesture !
After understanding the whole deal, we thought man, we must make a library where the gestures could be detected and user could simplify its use on the lines of usage of events like - onClickListner  / onTouchListner. So we started to code ! But man we love GOOGLE :)

We got link to this post. The guy has done all that we planned to do. Simply awesome!
So without taking those pains, we used his library and it worked like a charm! It gives you the direction of the swipe, the displacement, and whether it was really a swipe or a click ! I think all that one amateur would want !

The link to his blog is - Awesome Swipe Gesture Implementation

However, we would like to present the jist of the same in our words here in this blog as well.

Steps To Create -

  1. Copy this project into your workspace - Swipe Me
  2. Once done, add the .jar file to your library.
  3. Import the “SwipeMe.OnSwipeListener”.
  4. Set OnTouchlistener to the view object by sending OnSwipeListener as the listener.
  5. Override the onSwipe() method and do whatever you want
  6. Use the getSwipedTo() to know the direction of the swipe

The sample code -

Here is a sample code adding the swipe action and implementing the four direction swipe actions on a button:
import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
// importing the onSwipeListener
import SwipeMe.OnSwipeListener;

public class SwipeMeActivity extends Activity {
    /** Called when the activity is first created. */
    public void onCreate(Bundle savedInstanceState) {

        Button test = (Button) findViewById(;

        //adding onTouch action to test button
        //but by sending it the on swipe listener
        test.setOnTouchListener(new OnSwipeListener() {

            public void onSwipe(View v, MotionEvent event) {
                // TODO Auto-generated method stub

                //checking the direction of the swipe
                case SWIPED_LEFT :
                    //swiped to left
                    Toast.makeText(getApplicationContext(), "Swiped Left",
                case SWIPED_RIGHT :
                    //swiped to right
                    Toast.makeText(getApplicationContext(), "Swiped Right",
                case SWIPED_UP :
                    //swiped up
                    Toast.makeText(getApplicationContext(), "Swiped Up",
                case SWIPED_DOWN :
                    //swiped down
                    Toast.makeText(getApplicationContext(), "Swiped Down",
                case CLICKED:
                    Toast.makeText(getApplicationContext(), "clicked",

Thursday, 21 June 2012

ANDROID - Layout - Warm Up 1

The first thing that almost every soul who enters the mobile app biz plays with is - The Layout!

The most important challenge is to keep the best quality images at the same time keeping the APK size to the minimum. This is an attempt by Blot Canvas to make the issues faced by us - visible!

We would like to think of this a way to give back to the society - impart knowledge - making a note here that we have no other way to do so (no money Mr. Anderson).

Anyways, so to kick-start this blog, unlike iPhone, the variety of phones on Android platform are exorbitant. Hence, loads of display sizes that one needs to take care of in an application. Android has made it somewhat easy to manage - it has generalised the display sizes and folder-sliced them. So in effect there are 4 broad divisions of sizes that one needs to scale the images to make an application support all display sizes. The sizes are mentioned below -

Small - ldpi - 240x320
Medium - mdpi - 320x480
Large - hdpi - 480x800
Xtra Large - xhdpi - 800x1200

More about these sizes, the related tricks to keep your APK size down etc etc.