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.