Blog title not shown in WordPress.

This is one of the common problems found in the site hosted on wordpress.
If your blog title is not showing the title,

Then go to Settings-> General-> Blog title and set the blog title there.

If still the title is not coming..then you must have installed “All in One SEO” as plugin in your wordpress site or blog.
“All in One SEO” overrides the blog title. So what you have to do is go to Settings -> All in One SEO and set the blog title there.
This will solve your problem.
Good luck.

Crop an Image in ANDROID.

Cropping an image in ANDROID programmatically has always been a problem for ANDROID developers.
So Here I am putting a sample code to demonstrate this.
For cropping an image in ANDROID we need a source bitmap which is our image itself, the other one is the target bitmap which we have to
set the size as we want and a matrix.

Below code is a fully working code, just copy and paste this code to your new project.
The XML for the code is also provided below.

Make sure that you have an image named “image.png” in your resources.
Assuming the image to be of size 300×300 pixels.

package Move3.pack;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.view.View.OnTouchListener;
import android.widget.AbsoluteLayout;
import android.widget.FrameLayout;

@SuppressWarnings({ "deprecation", "unused" })
public class Move extends Activity {

	public FrameLayout board;
	public View part1;

	public void onCreate(Bundle savedInstanceState)
		 board = new FrameLayout(this);
		 board = (FrameLayout)findViewById(;
		 part1 = new View(this);
		 part1 = findViewById(;

	    	Paint paint = new Paint();
			Bitmap bitmapOrg = BitmapFactory.decodeResource(getResources(),R.drawable.image);

	        int targetWidth  = 300;
	        int targetHeight = 300;

	        Bitmap targetBitmap = Bitmap.createBitmap(targetWidth, targetHeight,Bitmap.Config.ARGB_8888);

	        RectF rectf = new RectF(0, 0, 100, 100);

	        Canvas canvas = new Canvas(targetBitmap);
	        Path path = new Path();

	        path.addRect(rectf, Path.Direction.CW);

	        canvas.drawBitmap( bitmapOrg, new Rect(0, 0, bitmapOrg.getWidth(), bitmapOrg.getHeight()),
	       		 			new Rect(0, 0, targetWidth, targetHeight), paint);

	        Matrix matrix = new Matrix();
	        matrix.postScale(1f, 1f);
	        Bitmap resizedBitmap = Bitmap.createBitmap(targetBitmap, 0, 0, 100, 100, matrix, true);

	        /*convert Bitmap to resource */
	        BitmapDrawable bd = new BitmapDrawable(resizedBitmap);


    	catch(Exception e){
    		System.out.println("Error1 : " + e.getMessage() + e.toString());



<?xml version="1.0" encoding="utf-8"?>



crop image in android Example
cropping image in android

If you got any errors please let me know.

Sprite Sheet Animation in Cocos2D – An Example


Suppose you have a sprite sheet of the desired animation you want. But how will you use that sprite sheet animation in your program using cocos2D? That’s simple. See the following code first.

//Initializing a CCSpriteBatchNode with our sprite sheet image
CCSpriteBatchNode *newSpriteSheet = [CCSpriteBatchNode batchNodeWithFile:@"jumpingOver.png"];

//Adding the spriteSheet to the layer & setting the z orientations
[self addChild:spriteSheet z:14];

//Creating Frames from the frames file jumpingOver.plist
[[CCSpriteFrameCache sharedSpriteFrameCache] addSpriteFramesWithFile:@"jumpingOver.plist"];

//Initializing a sprite with the first frame from plist
CCSprite *jumper = [CCSprite spriteWithSpriteFrameName:@"jump1.png"];

//Creating an NSMutableArray for adding the frames from plist
NSMutableArray *framesArray = [[NSMutableArray array] retain];

//Iterating for the total number of frames from plist
//Here supposing our jumpingOver plist have 15 images
for(int i=0; i<15; i++){
//Adding frames to our framesArray from the frames
[turningFrames addObject:[[CCSpriteFrameCache sharedSpriteFrameCache] spriteFrameByName:[NSString stringWithFormat:@"jump%d.png",i]]];

//Creating an animation using the frames in framesArray
CCAnimation *jumping = [CCAnimation animationWithFrames:framesArray delay:0.25f];

//Setting our jumper sprite sprite sheet animation to the position of one another sprite
//oldSprite is our previous sprite on that position we are adding the animation

//Creating action from the animation jumping
CCAction *jumpAction= [CCAnimate actionWithAnimation:jumping];

//running the action on jumper sprite with the sprite sheet animation action on jumpAction
[jumper runAction:jumpAction];

//Adding the jumper sprite to the layer with z orientation
[self addChild:jumper z:15];


Adding Image to a UIImageView using Image URL


Sometimes you need to add Image to a UIImageView from the URL of the image you got. In that case, this is how you can add image to the UIImageView.

NSString *picURL= @"";
NSData *picData = [[NSData alloc]initWithContentsOfURL:[NSURL URLWithString:mapURL]];
UIImage* picture = [[UIImage alloc] initWithData:picData];
[pictureView setImage:picture];
[picData release];
[picture release];

Here, pictureView is your UIImageView.

How to create a new Virtual SD card in emulator in ANDROID? How to start emulator with the created SDCard?


The first question is
1. How to create a new Virtual SD card in emulator in ANDROID?

Many times we may have not enough memory for our application to run on the emulator.
So what we do?
One method is to create new virtual device with more memory.
Another method is to extend the device’s internal memory.
Third method is to create an SD card for the emulator.

Here is how you create a new SD card for the emulator.
First you have to navigate to you android installation directory and go to tools from there execute this command

C:androidtools>mksdcard -l mySdCard 1024M mySdCardFile.img

A file image named “mySdCardFile” will be created with about 1024 MB memory or you can give it in KB also.

Now SDCard created.Check your C:androidtools directory and confirm that the image has been created.

SDcard created

2. How to start emulator with the created SDCard?

Try this in the command prompt
Note: Make sure your emulator(Here VD1.6 created by me) is not running.

C:androidtools>emulator -avd VD1.6 -sdcard mySdCardFile.img

Now go to Eclipse Open DDMS on the right top of the window and open the File-Explorer from the Window-Menu

There you will see the SDcard

No image

If you are not starting the emulator with the sdcard you will not see the sdcard here.

You can find more options on emulator here

How to create a scrolling ListView in android?

ListView is like a tableView in iPhone or iOS . In this example i will show you how to add a String Array in to the ListView and also make the listView Scrollable.

First the xml file . Here the line


will make the scrolling vertically

<?xml version="1.0" encoding="utf-8"?>


Now the java file

package com.Ch.Example.pack;

import java.util.ArrayList;
import java.util.List;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.AdapterView.OnItemClickListener;

public class Example extends Activity
    /** Called when the activity is first created. */
	ListView list;
	private List<string> List_file;
	public void onCreate(Bundle savedInstanceState)
        List_file =new ArrayList<string>();
        list = (ListView)findViewById(;

	private void CreateListView()
		 //Create an adapter for the listView and add the ArrayList to the adapter.
		 list.setAdapter(new ArrayAdapter<string>(Example.this, android.R.layout.simple_list_item_1,List_file));
		 list.setOnItemClickListener(new OnItemClickListener()
				public void onItemClick(AdapterView<?> arg0, View arg1, int arg2,long arg3)
					//args2 is the listViews Selected index

The screen will be like this

Here is a other useful posts related to listviews.

1. ListView with Sections in android.
2. A Simple Layout with two listViews.

How to read a folder in the assets directory and read files from it in android?

File reading is important in android. For the put the files in the assets folder.

We can able to read

  • foldername
  • filename
  • Contents of the file

First we read the name of the folder.

private String folder_array[];
AssetManager mngr_spinner = getAssets();
         //"air" is the name of the folder...
	folder_array= mngr_spinner.list("air");
catch (IOException e1)

“folder_array” contains all the names of the folder
Then if the path is set to

folder_array= mngr_spinner.list("air/Buttons Events");

Then the list of file name is got.
If you want to read the file content then do the following..

InputStream is;
	is = getAssets().open(air/Buttons Events/filename);
	int siz = is.available();
	byte[] buffer = new byte[siz];;
        //This text contains the content of the file..
	String text = new String(buffer);
catch (Exception e)
	 Toast.makeText(CheatSheet.this,"File Not Found Error.Please ensure that file is not deleted.", Toast.LENGTH_SHORT).show();

How to prevent collision between connected bodies in Box2D ?


While using Box2D , in many cases you may need to connect two bodies together. But the collision between them during motion is not what you preferred! So how can you prevent those bodies being connected in Box2D from collision?
Use the line of code to prevent the collision.

jointDef.collideConnected = false;

Copying a Sprite Image to another Sprite in Cocos2D


Suppose you want to copy a sprite image to another new sprite while using cocos2D. What you do?
See the following code…

Let oldSprite be your first sprite

CCSprite *oldSprite = [CCSprite spriteWithFile:@"ImgOne.png"];

And newSprite be your second sprite

CCSprite *newSprite  = [CCSprite spriteWithTexture:[oldSprite texture]];

That’s it! Done! Now newSprite too contain ImgOne as Sprite.


Playing sound on the Mac Desktop in Objective C.

There are different ways for playing sound on the Mac in Objective C.

Let’s look at some of the methods..
1. Play by filename.

           NSSound *mySound = [NSSound soundNamed:@"sound"];

if you have no file named “sound” in your application’s main bundle, then it will return nil.

2. Play by pathName

           sound = [[NSSound alloc] initWithContentsOfFile:@"/Volumes/Audio/sound.aiff"

3. Play by URL

        NSURL *soundURL = [NSURL
        NSSound *sound = [[NSSound alloc] initWithContentsOfURL:soundURL

Then to play the sound add

         if (![sound isPlaying])
                [sound play];

To pause the sound

               [sound pause];

To stop the sound.

              [sound stop];

To resume the sound

             [sound resume];

Please leave your valuable comments if this post was useful…..

Delete a substring in Objective C, Iphone , Mac………….

This code snippet deletes a substring from a original string..

/** initialize two strings **/
NSString *string = @"This is heaven";
NSString *part = @"heaven";

/** Get the range of the substring in the original string **/
NSRange range = [string rangeOfString:part];

/** Delete the substring from the original string **/
[string deleteCharactersInRange:range];

Please leave your valuable comments………

ToolTip Sound in Adobe AIR/FLEX…

Sometimes we may need to have a sound when we hover over something, i.e when a tooltip appears.
Actually this can be done easily by adding an eventListener to the corresponding control.
Take a look at the example.
This line is the important line.

      myLabel.addEventListener(ToolTipEvent.TOOL_TIP_SHOW, myListener);

The function myListener gets called when we hover over the label thus producing the sound.
What you have to do is to just copy and paste the following code to your file.



     private var myToolTipSound:Class;
     private var mySound:Sound;

     private function init():void {
        myLabel.addEventListener(ToolTipEvent.TOOL_TIP_SHOW, myListener);
        mySound = new myToolTipSound();
      public function playSound():void {;
     private function myListener(event:ToolTipEvent):void {

Encapsulation Using Properties in C#.NET / ASP.NET


Let’s see how encapsulation can be implemented using properties in C#.NET/ASP.NET.
Let’s see the code first.

using System;

public class Student
    private int stud_id = -1;

    public int ID
            return stud_id;
            stud_id = value;

    private string stud_name = string.Empty;

    public string Name
            return stud_name;
            stud_name = value;

public class StudentManagerWithProperties
    public static void Main()
        Student studObj = new Student();

        studObj.ID = 7;
        studObj.Name = "Aamir Khan";

            "ID: {0}, Name: {1}",
            studObj .Name);


Ok. Here Student class has two properties ID & NAME. Also two private variables or fields stud_name & stud_id, both are encapsulated by our ID & NAME properties. And also two accessors for setting and getting values from fields. Set accessor set the value to the field. Note that the ‘value’ used here is the keyword! This value is assigned by calling function. StudentManagerWithProperties uses the ID & NAME properties as we can see.


AlertView with textbox in iPhone, Objective C.

Often we see alerts with text message or title in it.
But actually we can customize alerts. We can place any views inside it.
We can place a textView(TextField) , imageView etc in it.
Take a look at this simple example that places a textbox inside an alertView.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Title goes here!!"
                            message:@"My Message"
                            delegate:self cancelButtonTitle:
                            @"Cancel" otherButtonTitles:@"OK", nil];
UITextField *TF = [[UITextField alloc] initWithFrame:CGRectMake(12.0, 45.0, 260.0, 25.0)];
[TF setBackgroundColor:[UIColor ClearColor]];
[alert addSubview:TF];        /** adding the textfield to the alertView **/
[alert show];
[alert  release];

Please leave your valuable comments…..

Using GridView in ANDROID….

GridViews are those in which you can arrange elements in a two dimensional grid.
It is what you see in the gallery where images are arranged. Here images are arranged in a two dimensional grid.
Copy the below code and save it as “”

package com.pack;
import android.os.Bundle;
import android.view.View;
import android.widget.AdapterView;
import android.widget.GridView;
import android.widget.Toast;
import android.widget.AdapterView.OnItemClickListener;
public class MyGridView extends Activity {
public void onCreate(Bundle savedInstanceState) {
GridView gv = (GridView) findViewById(;
gv.setAdapter(new ImageAdapter(this));
gv.setOnItemClickListener(new OnItemClickListener() {
public void onItemClick(AdapterView parent, View v, int position, long id) {
Toast.makeText(MyGridView.this, "" + position, Toast.LENGTH_SHORT).show();

/********************************* End of ****************************** **/

Now create another file named “” and copy the below code to it.

package com.pack;
import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
lass="Apple-style-span" style="font-family: Times, 'Times New Roman', serif;">import android.widget.ImageView;
public class Images extends BaseAdapter {
private Context ctxt;
public Images (Context c) {
ctxt = c;
public int getCount() {
return Ids.length;
public Object getItem(int position) {
return null;
public long getItemId(int pos) {
return 0;
public View getView(int pos, View convertView, ViewGroup parent) {
ImageView imgView;
if (convertView == null) {
imgView = new ImageView(mContext);
imgView.setLayoutParams(new GridView.LayoutParams(85, 85));
imgView.setPadding(8, 8, 8, 8);
} else {
imgView = (ImageView) convertView;
return imgView;
private Integer[] Ids = {
R.drawable.img_2, R.drawable.img_3,
R.drawable.img_4, R.drawable.img_5,
R.drawable.img_6, R.drawable.img_7,
R.drawable.img_0, R.drawable.img_1,
R.drawable.img_2, R.drawable.img_3,
R.drawable.img_4, R.drawable.img_5,
R.drawable.img_6, R.drawable.img_7,
R.drawable.img_0, R.drawable.img_1,
R.drawable.img_2, R.drawable.img_3,
R.drawable.img_4, R.drawable.img_5,
R.drawable.img_6, R.drawable.img_7
/*********************************** End of**************************** **/

Note: Please make sure that you have images named img_0 to img_7 in your res/drawable folder.
Please leave your valuable comments if this post was useful…..

Android TableLayout

In android there are different layouts and we often confuse about which one to use. Even if we select one, it is little complicated.

So this tutorials is to show you about the TableLayout

Here i first created linear Layout in which a Table Layout is added

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
		<Button android:layout_width="wrap_content"
		<Button android:layout_width="wrap_content"


Here you can see that the first row ie, the EditText length is limited to 1 column and so it is not looking good. So we can make the EditText span across two column by adding this line to EditText


Now we can position the TableLayout in the center of the screen by adding this to TableLayout

android:layout_gravity = "center_vertical"

Now we think of aligning this to center horizontal as

android:layout_gravity = "center_horizontal"

But this wont work. This is because of LinearLayout and here the positioning is restricted.
But their is solution “Relative Layout” and positioning is easy by using this layout.

I will cover this in my next Post

Alert Button with Image in Adobe AIR/FLEX…

We usually see only alerts with text only, but in Adobe AIR and FLEX we can have alerts with our images in it. That’s really cool right.
Take a look at this simple example. It places an image in the alert.
Make sure that you have the image named “alert_image.png” in your “src” folder or otherwise give the specific path.


No Image

How to Disable Right Click on HTML page using jQuery ?


In some special cases you may need to disable the Right Click option on HTML page you are using.
An easy way to do it using jQuery is follows. Use the following code in the HTML page where you want to disable Right Click.

        return false;


Sorting ArrayList Elements Alphabetically in ASP.NET – Sort()

In order to sort elements in ArrayList using ASP.NET we can use the Sort() method.
It will sort ArrayList Elements alphabetically.

This will sort the ArrayList elements alphabetically.


How to play music in cocos2D or Box2D, iPhone?

This simple code plays a music……..

[[SimpleAudioEngine sharedEngine] playBackgroundMusic:@”my_music.mp3″];

For stopping the music use this…….

[[SimpleAudioEngine sharedEngine]stopBackgroundMusic];

To pause the music use this line of code…..

[[SimpleAudioEngine sharedEngine] pauseBackgroundMusic];

How to make gear joint in Box2D, iPhone?

Gear joints are one of the real specialities of Box2D.

By creating gear joints between two bodies you can actually simulate a real world gear. For creating a gear joint you need two bodies connected by a revolute or prismatic joint.

The below code creates two bodies in the shape of a circle which is actually attached to the ground. however you can also create joints without joining it with the ground. Here you have to make a ground with possible four fixtures or no fixtures simply creating a body.

        b2Body* body1 = circle1;
        b2Vec2 pos1 = circle1 -> GetPosition();//get position of first body.....
        b2Body* body2 = circle2;
        b2Vec2 pos2 = circle2 -> GetPosition(); // get position of second body....
        revJointDef.Initialize(ground, circle1, pos1);
        b2RevoluteJointDef revJointDef2;
        revJointDef2.Initialize(ground, body2, pos2)//revolute joint is initialized
        joint1 = world->CreateJoint(&revJointDef;); //First joint.....
        revJointDef2.maxMotorTorque = 20000.000000f; //connect a motor to the joint2
        revJointDef2.motorSpeed = 120.000000f / 60; //set the rotation speed.....
        revJointDef2.enableMotor = true;            // enable the motor.....
        joint2 = world->CreateJoint(&revJointDef2;);  //Second joint.....

        gearJointDef.bodyA = body1;
        gearJointDef.bodyA = body2;
        gearJointDef.joint1 = joint1;
        gearJointDef.joint2 = joint2;
        gearJointDef.collideConnected = true;
        gearJointDef.ratio = circleShape2.m_radius/circleShape1.m_radius;
        world->CreateJoint(&gearJointDef;); // this line creates the joint.

Please leave your valuable comments……………………..

Swing JPanel with background image

This code add an image to Jpanel.

JPanel panel1 = new JPanel();
JFrame recursion_frame = new JFrame();

BackgroundPanel stack_image1 = new BackgroundPanel("Recursion.jpg");

panel1.setLayout(new BorderLayout());
recursion_frame.setContentPane(panel1);  ///adding to panel...
recursion_frame.getContentPane().add(stack_image1);  //adding image to panel...

Position swing window in center of the screen

In some case we need to position the window in the center of the screen . The same effect can be achieved by hard coding the center points .But in that case the window position change when the screen resolution changes

This code will position the window in center irrespective of different screen resolutions

public JFrame stack_frame = new JFrame();