android intent tutorial

March 14, 2011 2 comments

Today i am going to talk about something called intent. To get more in depth knowledge about android you should have basic understanding about intent.

Intent comes with your intention. It’s pretty interesting after you really understand what this is for.

Android uses two kinds of intent:

  1. Implicit Intent
  2. Explicit Intent

Let’s see a real world example, say you want some information about intent but you don’t know where to get it but you only know you want to see information about intent. So what do you do? You will be open up your browser -> go to google -> and enter something about intent and search

Now what google will do, it will search its entire database and try to match with those that best describe your entered keywords and return it to you.

What if you knew that in my blog there is a post about intent that badly describe about intent and still you wanna see that, then you will probably enter my blog address in your browser url instead of going to google. Though it’s not a bad idea to go to google for various type of information. At least I would do that. 🙂

In first case what did you do?

You did give some data to google and google fired something at you when it found something using that data.

This will be implicit since you didn’t know where in the world has a server which reside the appropriate data in terms your given data.

In the second case you did know explicitly where can you find your data, so you explicitly told your browser to take you there.

And that is also the case for android too.

Intent intent=new Intent(Intent.ACTION_PICK,

is used with implicit intent. As you can see here, in creating new intent we need an action and the data that action will be performed on. Now startActivityForResult will launch the activity that uses “content://contacts/” kind of data. As for the action though you don’t know if they don’t tell you what kind of action is permitted on that application’s activity but we know in the case we are using now because Intent.ACTION_PICK is supported by android’s own contact application so this intent will launch android’s native contact application where we can pick a contact that we choose and return with the result in your activity. As with previous example here you only knew what kind of data you needed what you wanna do with that data, now android will lookup for an appropriate application that uses this kind of data and also permit the kind of action you are requesting since some application’s data will not be available to others to use. If any appropriate application is found android will start that activity and show it to you to do your work.

As of explicit:

Intent intent=new Intent(PageOne.this,PageTwo.class);

You can easily guess that in here I’m in page one and I want to go another activity that is page two.

Here I explicitly told which activity I want to start.

Notice that I used startActivityForResult for the first one and startActivity for the second one, this may confused you a little bit, I will explain it to you later.

I think that explain not much but little bit about intent.

It will be more clear if you see some example application.

Using Implicit Intent:  ContactPicker

Using Explicit Intent: ReportGenerator

or you can check it from here:
svn checkout

this entire application uses explicit intent to go from one page to another.

Thank you for checking by and  if you have any question or suggestion please do comment. I appreciate that very much.


Categories: Android

Difference between interface and abstract in OOP

October 11, 2010 Leave a comment

Now what is interface really?Interface is kind of like template.In that you tell people what standard they should follow but not telling them how to.For example.. assume you create box when people order it to you.In that case every  time they order a box with telling you ”i want some box like that you made for my neighbour”  then you define properties and  behaviour of box yourself.After some days your  workload has been so overflowed that you have to open your own company and need to recruit some worker in that company.And later you’ve to open some branches for it.Now in that case again when order comes to you ,you are not going to go to the every branch to do the job.You need to give some kind of standard to the branch manager’s or ceo whatever you call about how they should  make a box.Give them some template of box where you define what a box should behave when they create it.Tell them something like this:

public interface boxTemplate{

double setWidth(double w);

void getWidth();

double setHeight(double h);

void getHeight();

double setLength(double l);

void getLength();

double getArea();


And then one of the branch,design a box class something like this:

public class box1 implements boxTemplate{

public double width;

public double height;

public double length;

public box1(double wd,double hg,double ln){





public void setWidth(double w){



public    double getWidth(){

return width;


public    void setHeight(double h){



public    double getHeight(){

return height;


public    void setLength(double l){



public    double getLength(){

return length;


public    double getArea(){

return (width*height*length);



No matter how all branches want to make a box, should always follow your template .Box class design of different branches can differ from one another but since they all are implementing your boxTemplate you know that what behavior a box can behave when it’s ready no matter what it’s origin is.


One day somehow you get a huge order of making box but with some condition.By imagining that you can be next millioniare you accepted those condition.Now the condition was that they want box with same width and length but with red,orange,yellow,green,black,white  in  color and different type of height.Since it’s a big order  you call your three branch manager.And give all of them a new kind of template like this:

abstract class boxNewTemplate {

public double width=22.0;

public double length=22.0;






public void setWidth(double w){



public    double getWidth(){

return width;


public    void setLength(double l){



public    double getLength(){

return length;


abstract void setHeight(double h);

abstract double getHeight();

abstract void setColor(int colorCode);

abstract double getArea();


And then tell one of them to make boxes where half of them should be red and half orange and you also told the same to others for making other colors.After that one of them create a box class like this:

public class box2 extends boxNewTemplate{

static final int RED=1;

static final int ORANGE=2;

public double height;

public box2(double hg,int colorCode) {





public  void setHeight(double h){



public    double getHeight(){

return height;


public    double getArea(){

return (width*height*length);


public void setColor(int colorCode){


//give the color

}else if(colorCode==ORANGE){

//give the color


//do nothing




So the meaning of abstract class is that you do some implementation of your own to a class but some of them you leave for others.So if someone wants to include your class in their system they just have to implement those things that you did not in that class and you do that by telling them it’s abstract.Now if a method is not implemented yet which is abstract but most of the method of that class are how they are going to know that some of this class’s mehod is not implemented yet if you do not put abstract  before that class name.Think about it.

I think that explains a lot about interface and abstract.

Again what you are reading in here is the concept that i figure out myself.It can contain any or many conceptual error.If you find some,feel free to tell me about it.And also if you have any question feel free to ask.


Categories: Java, OOP Tags: ,

Concept of Object in OOP

October 9, 2010 Leave a comment

When we  first try to learn java(Object Oriented Programming),we all must have a conflict with Object.To be a developer having the idea about,”what is object?” is must.You must have a basic understanding about Object.Cz ,by the time pass by you will see that all things ,if it gui or others it always end up with concept of Object.So it is really very very important to have clear concept of Object Oriented Programming.

Now when u try to understand oop the very first question comes in mind is that What is this Object means?

Object is something that has some properties.And has some behaviour that acts with those properties.I am going take an example of Box.Now a box is cube like thing.It has width,height,length.If you assume those are it’s properties then i will say finding it’s area can be considered as it’s behaviour .Again if you are still confused about behaviour now what is behaviour in plain text?Think about yourself.Can you feel your skin?… J of course you can.When it is cold what do u do?And when it is summer i don’t think you do same thing as you do at the time of winter.So i can say the behaviour of your ,change when the behaviour or properties of something other change.See deep inside this concept,the behaviour change of weather will change the body temperature property of your thus your behaviour will also change.Go back to the box.If you change any property of it,it will affect the area of it.Now you can think of as many as behaviour you can.It’s up to u.If someone told you that i want some box with different type of area and also with different type of color.Then you can add a property of color with also add one extra behaviour in it that is going to set it’s color.You can imagine anything as object.From electron to whole universe.Since you are probably not here to assume the whole world as object but  to understand object in respect to programming language.What about a window or the browser you are seeing or a button?All can be imagined as object.A window has title bar, closing option,minimizing option e.t.c.When you click on minimize, it’s behaviour should be minimizing the window.What about the properties clicking on it?Clicking on it will fire a change in properties will fire to it’s corresponding behaviour.Take another example of human.The lowest distance of human eye that it can see is 25cm.Now if you are wearing a glass or your friend is,tell yourself or him what happened why are you wearing a glass?Probably the answer will be lowest distance of eye has been reduced or increased.So if i tell you lowest _distance is a property of another property (can also be considered  as object itself)of human which is eye.Well sometimes creator create human’s with a defected eye or  anything can happen to one’s eye.Every human has a property of eye and it can be true or false depends on ,if it can see or not.Now the behaviour of eye is to see something where it has a property of seeing something with minimum distance of 25cm.If this 25cm is changed by some another behaviour then it will fire a change in the lowest_distance thus the behaviour  of eye change thus you or your friend or your neighbour wear a glass of plus or minus power.

I think that’s explain a lot what the object is.

One thing you should know that what you are reading in here is the concept that i figure out myself.It can contain any or many conceptual error.If you find some,feel free to tell me about it.And also if you have any question feel free to ask.



Categories: Java, OOP Tags: ,

beginning android with hello world

September 27, 2010 Leave a comment

In my last post we have talked about how to configure everything to start your android development.
Now in this post i will show you how we can create a very basic “HelloWorld” application for android.
And after that we will be doing some modification on our apps.

so are you ready to go..”yeah!”.but i am not ready.just kidding 🙂


1:Do i have to tell you that “Open your eclipse”?????? 🙂 i think not
you do what i did in my first android tutorial to create an new android project.

2:Ok, now that you’ve created a project run it as android application.

3:There you go…. you should see a virtual device saying “Hello World  (probably your project name)”.

4:Now we want to change something in it.Say… “Hello saiful103a”
So how do we do that
i.go res->values and open strings.xml
ii.Now you should understand where does this “Hello World ..” was coming from
iii.Now you’d think how this sentence is accessed from main file well then open gen->
you should see an inner class called string. In that method what you see compare it with the strings.xml file
then you will understand not everything but enough to start with.
iv.Oh did you change the sentence from hello world to hello saiful103a.
v.Now run it….. voila….

is it worked ????yes then we should take a coffee break …..:)

5:Now we want our text to be red
create a file named colors.xml into res->values folder
inside that paste the below code
<?xml version="1.0" encoding="utf-8"?>
<color name="colorOfText">#ff0000</color>

6.Open main.xml you should see a TextView element this element decide how the text will appear
on the screen upon it’s given attribute.
since we want to change color of the text add an extra attribute
after that textview should be seen like:

save it….
run it……….

so isn’t that (i will not say awesome cz we do not yet explored it deep enough but we will be) goooooood..:)

but that’s it for today…


Categories: Android, Java

beginning android development

September 24, 2010 2 comments

Last few days i was exploring about android development.And you know what i found ,I found it is pretty interesting.You do not have to be a geek to start with android,though i first thought that but now i am starting to like it.All you have to know is basic understanding about java.Enough talking,

So let’s get started for android:
At first you need to download the android sdk.
you can have it downloaded from
And one more thing ,i am using windows as my OS.
Download the sdk for windows.
After downloading the .zip file extract it and put your extracted folder into c:\ drive
Go into the folder and you will see a file named “SDK Manager.exe”
Double click on it.Then you should see a window for “Android SDK and AVD Manager”.
Click on available packages and expand the

link and you will see the most updated API packages available.

android sdk and avd manager

Select most updated packages as your API and also select samples as you can explore android more in depth and install it.It will download the API into platforms folder.And also will create folder for sample code.Now that you’ve downloaded the SDK, you have to choose which IDE you should use.Though you can code without any IDE but notepad but we don’t want any trouble ‘do we?’.Since everyone is comforting in using eclipse for android development and since it is open source so we also will use that.
If you don’t have eclipse then download it from the eclipse site.
Well i have downloaded eclipse for java.Also download the windows version.
Extract it and run your eclipse ide.
After that you need to download a plugin for android that is called Android Development Tools “ADT”.
Go to

“Help”->”Install New Software”->”Add”->Name:”ADT”,Location:”;
Under the developer tools check both DDMS and ADT.I will explain what is DDMS for later.And then install it.

Since everything is ready now we just need to integrete the sdk with eclpise so that eclipse can use the api provided by sdk and other resources.

Go to “Window”->”Preferences”->”Android”
under android locate the sdk location in your hard drive.
eclipse will do the rest for you.
Next thing you need to create a virtual device called emulator.
Go to window->Android Sdk and AVD Manger
Under virtual devices
Select ‘New‘ ,name your emulator whatever you like, select target as best available api,
give a size of the sd card if your application needs it and then ‘create avd‘.
Also you can have multiple AVD if you want.Then you can specify the emulator in which you want to run with.
And that’s it.
You are ready to go with android.

Now that you are ready

Go to your eclpise and start a new project
under Android select Android project
Do something like this:
Creating project

click finish
And then will see something like this:
android project
Right click on projeect and go to-> run as->Android application
then just wait for the magic.After appearing of your virtual mobile(emulator) click menu,app will

start automatically after awhile.
As i was saying you can use specific emulator if you want, so right click on project
got run as->run configurations, under that go target and check which AVD you want to launch.

And that’s it for today.I’ll keep update in my blog as my path of exploring android goes into deeper.

If you have any questions or any suggestions please inform me.


Categories: Android

jQuery bangla tutorial part-3

November 14, 2009 1 comment

আমি jQuery Object Accessors সর্ম্পকে বলব,এর অর্থ থেকেই হয়তবুজে গিয়েছেন এদের কাজ হল
document এর object গুলোকে access
$(“a”).click(function () {
$("div").each(function (i) {
if ( != "red") { = "red";
} else { = "";

এখানে আমি নামের একটা link খুজছি যেটাতে click করলে পুরো document-এ যতগুলো div element আছে তাদের সবার color red না থাকলে red কর,আর red থাকলে এদের আগে যে color ছিল তা কর।
এখন আপনার প্রশ্ন হতে পারে document এ ত আরো অনেক link থাকতে পারে তখন?উত্তর হল সে সময় আপনি যদি প্রতিটা link এর id বা class আলাদা করে দেন তাহলে পরবর্তীতে দেখবেন কিভাবে আপনি এই id বা class এর মাধ্যমে specifically কোনলিঙ্ক element কে select করে action assign করতে পারবেন।কি এখন তবুজতে পারছেন jQuery আসলেই সহজ।আসলে jQuery কে বানানোই হয়েছে এই উদ্দেশ্যে ।যাতে খুব কম code লেখে javascript এর অনেক বড় কাজ করা যায়।
আপনি যদি dom বুঝেন তাহলে লক্ষ করলে দেখবেন উপরের এই কাজটুকু যদি করতে আপনাকে হয়ত 10-20 বা আরো বেশি লাইনের বেশি code লেখতে হতে পারে।তার চেয়ে এটা ব্যবহার করা সহজ নয় কি?
$(document.body).click(function () {

var n = $(“div”).size();
$(“span”).text(“There are ” + n + ” divs.” +
“Click to add more.”);
}).click(); // trigger the click to start

এখানে দেখুন আপনি যখন document.body তে click করবেন তখন
document.body তে আমি $(html) এর মাধ্যমে একটি

element add করছি।তবে এবার করছি একটু ভিন্নভাবে তাই না?একটু খেয়ালকরলে দেখবেন দুটা আসলে একই।এখন ভাবুনতো আমি আপনাকে দেব আর আপনি আমার কাছ থকে নিবেন ,এ দুটার মধ্যে পার্থক্য কি?হা হা হা,একই তাই না?প্রথম আমি element তৈ্রি করে তা document body তে append করতে বলেছি এখন document body তে append করতে বলছি div নামের একটা element কে। তারপর n নামের একটি variable এর ভেতর total document এ কতগুলো div element আছে তা গননা করে একটা integer মান রাখছি size() function এর মাধ্যমে।
তারপর “span” নামের কোন element থাকলে এর ভেতর text এর মাধ্যমে লেখছি div কয়টা আছে।আর সবশেষে আমি নিজেই একটা click করে দিচ্ছি document ready
হওয়ার সাথে সাথে click() এর মাধ্যমে “একে সাধারন ভাষায় বলে trigger করা”।এখন আপনি লক্ষ করে দেখবেন আপনি যতবার click করছেন ততবার একটি করে div add হচ্ছে আপনার document এ, এবং span এর ভেতর লেখাও প্রতিবার change হচ্ছে। সবচেয়ে ভাল হয় আপনি যদি আপনি css এর মাধ্যমে div এর border , color দিয়ে দিলে । এ কাজটি করতে পারেন css এর মাধ্যমে,আপনি নিচের কোডটি head এর মাঝখানে লিখুন।

div { width:30px; height:20px; margin:6px; float:left;
background:red; }
span { color:red; }

$(document.body).mouseout(function () {

var n = $(“div”).length;
$(“span”).text(“There are ” + n + ” divs.” +
“Click to add more.”);
আসলে length এবং size() এর কাজ একই ।তাই আমি আর বেশি কিছু বললাম না length সম্পর্কে ।তবে এখানে একটা কথা বলি trigger নিয়ে ।trigger ও jquery র আর একটি function. size() এর উদাহরণ এ প্রথম click টা আমি
কিভাবে করেছিলাম? Code এর শেষে click() দিয়ে trigger করে। তাই না? এখানে ও একই কাজ করেছি ।তবে একটু ভিন্নভাবে, trigger function দিয়ে। আমি trigger function এর ভেতর বলে দিচ্ছি তুমি mouseout নামে যে event টি আছে সেটি execute কর প্রথম বার page ready হওয়ার সাথে সাথে ।সে ও তাই page ready হওয়ার সাথে সাথেই mouseout নামের event
টি execute করে ।
And that’s it for today..
one thing again–আমি এই টিউটরিয়ালটা-ও first টিউটরিয়ালটা-r সাথেই লিখেছিলাম। খালি copy-paste করার বাকি ছিল।
and it was last part that was written but now i’ve to write again
for new tutorial

Categories: JavaScript, JQuery

jQuery bangla tutorial part-2

November 8, 2009 Leave a comment

আমি যে উদাহরণ গুলো দেখাব তাতে আমি সম্পুর্ণ কোড দেখাব না।jQuery র কোড গুলো আপনাকে আবশ্যই এর ভেতর tag দিয়ে লেখতে হবে।
Javascript এ যারা window.onload() function নিয়ে কাজ করেছেন তারা হয়ত খেয়াল করেছেন, এর মাধ্যমে কল করা কোন ফাংশন তখনই execute হয় যখন page এর সব object ও content load হয় ।মানে হচ্ছে কোন image যদি কোন কারণে লোড না হতে পারে তাহলে আপনার onload() এর দ্বারা যে ফাংশন কল করা হয়েছে তা আর execute হবে না।jquery তে .ready() function অনেকটা onload এর মত।difference হল এটাতে কোন page এর dom object গুলো যদি jquery হাতে পায় তাহলেই সে তার কাজ শুরু করে দেয় ।আর dom কে আপনি html এর বড় ভাই-ই বলতে পারেন তাই এগুলো একটু তাড়াতাড়ি-ই load হয় ।কারন,আপনি যদি আমাকে বলেন,তাহলে আমি বলব একটি page এ h1 নামের কোন element থাকলে সেটা লোড হতে যদি কোন সমস্যা না হয় তাহলে dom load হতেও কোন সমস্যা হওয়ার কথা না।
আর একটা জিনিস হল ready() function টি আপনার যতবার দরকার ততবার-ই কল করতে পারবেন ।
মাঝে মাঝে $(document).ready() ; কে “ $(); “ দিয়ে replace করে shortcut-এ

$ (function(){ your code here });

লেখা হয়।
চলুন এখন jQuery function গুলোর দিকে নজর দেই
jQuery( html ) / $(html):
ধরুন আপনি চাচ্ছেন user কে তার action এর উপর depend করে কোন লেখা দেখাবেন,যেমন




এখনই কোন action define করলাম না বুঝার সুবিধার জন্য।এই কোডটি আপনার page এ একটা Hello লেখা দেখাবে।এখানে যা হল,তা হচ্ছে
আমরা $(এখানে html code লেখেছি) পরে তা appendeTo() দিয়ে html body তে add করেছি ।যদিও আপনি html source code দেখলে Hello লেখা খুজে পাবেন না। পরে action assign করলে আরও ভালো করে এ জিনিসটি বুঝবেন আর এর কাজটা দেখবেন কত মজার।
চলুন এটাতে একটা action assign করি




এখানে আমি যা করতে চাচ্ছি তা হল Hello লেখাটিতে যখন কেউ click করবে তখন একটা function কাজ করুক,এবং ‘this’ means->

এর মধ্যেই

“jQuery লেখাটা দেখাও,যেখানে Hello লেখাটা আছে এবং আমরা এ কাজটি করছি .text() এর মাধ্যমে।দেখলেনত কত মজার।এভাবে আরও কিছুদুর এগুলে আপনি নিজেই user এর এক click এ পুরো page এর চেহারা বদলে দিতে পারবেন।এখানে text() এর কাজ নিয়ে আমরা পরে বিস্তারিত বলব।

আমি এই টিউটরিয়ালটা first টিউটরিয়ালটা-r সাথেই লিখেছিলাম। খালি copy-paste করার বাকি ছিল। করব করব বলে করা হয়ে উঠে নাই।আজ করে ফেললাম।

you can find similar post in
if you have any question you are welcome…


Categories: JavaScript, JQuery