Android SDK problem on Windows 7

One week ago while trying to download from Android SDK in Windows 7 on my friend pc, i saw an error that it couldn’t download the files from Android Code repository. So search i on google and found a solution.

1. Write click on the Eclipse icon and click run as administrator and launch the SDK manager
2. Or You can follow the same thing for SDK manager directly

Later i found that if your software have some issues with writing data on computer try to follow the above method.
Same goes for your custom .bat or .cmd file.

Adding Bangla Font (or other) on Android Emulator (MAC LION)

1. Go to
2. Download any of the font like for SolaimanLipi
3. Open Eclipse go to assets folder and paste the font
4. Now write the following code

TextView tv3 = (TextView) findViewById(;  
Typeface font = Typeface.createFromAsset(getAssets(), "SolaimanLipi-8-Jan-2011.ttf");  

5. Run the emulator.

Thanks to IMRAN KADER vaia!

For windows

Android Tips

1. Eclipse shortcut for import package
Windows = Ctrl-Shift-O
Mac = Cmd-Shift-O
2. Eclipse shortcut for Code Indentation Shortcut
Windows = Ctrl + A then Ctrl + Shift + F
Mac = Cmd + A then Cmd + Shift + F
3. Eclipse shortcut for show line number
Windows = Ctrl + F10 then n
Mac = Eclipse -> Preferences -> General -> Editors -> Text Editors -> Show line numbers
4. Comment rule for XML

<!-- this is a comment -->

Eclipse shortcut for Comment
Windows = Ctrl + /
Mac = Cmd + / or Cmd + Shift + C
5. Comment rule for JAVA

//this is a comment or /* this is a comment */

Windows = Ctrl + /
Mac = Cmd + / or Cmd + Shift + C
6. Eclipse shortcut for auto complete
Windows = Ctrl + space
Mac = Ctrl + space

Fun With Unicode!

Run this code in java IDE like DrJava! and see the output

\u0070\u0075\u0062\u006C\u0069c class A \u007B
    \u0070\u0075\u0062\u006C\u0069c \u0073\u0074\u0061\u0074\u0069\u0063 \u0076\u006F\u0069\u0064 \u006D\u0061\u0069\u006E \u0028\u0053\u0074\u0072\u0069\u006E\u0067 \u0061\u0072\u0067\u0073 \u005B\u005D\u0029 \u007B
    \u0053\u0079\u0073\u0074\u0065\u006D.\u006F\u0075\u0074.\u0070\u0072\u0069\u006E\u0074\u006C\u006E\u0028\u0022\u0048\u0065\u006C\u006C\u006F \u0057\u006F\u0072\u006C\u0064\u0022\u0029\u003B

Fibonacci number

Leonardo Pisano Bigollo introduced the Fibonacci sequence. He was an Italian Mathematician.

0, 1, 1, 2, 3, 5, 8, 13, 21

Each number is the sum of the previous two numbers.
Mathematical representation of Fibonacci sequence is

Fn = Fn-1 + Fn-2, where F0 = 0 and F1 = 1

We can Generate Fibonacci numbers using Dynamic Programming in O (n) and also find a particular Fibonacci number in O (log n).

S. Mahbub – Uz – Zaman
Monday, September 26, 2011


A number is a prime number if that number has precisely two distinct divisors, one and itself. First ten prime numbers are

2, 3, 5, 7, 11, 13, 17, 19, 23, 29

So, if we can find that N has two divisors than it’s a prime number else not, this is actually brute force approach and the complexity is O (N). How we do that, starting from 1 to N we have check if N is divisible by 1, 2, 3, ….., N each time it divide we increment our divisor count by one and at the end we will check if the divisor count is 2 or not.

Can we do better, yes we can. Look carefully the only even prime is 2. If we add an if condition that if the number is 2 return true else false if the number is even, because other even numbers can’t not be a prime number. For even numbers the complexity becomes O (1). So what about odd numbers? How can we improve that? We can reduce the complexity for odd number O (N / 2). See we don’t need to divide by even numbers because the Number N is an odd number, so it will never be divide by an even number. So we have to check if N is divisible by 1, 3, 5, 7, 9, 11, 13, 15 …. N.

We never satisfied! We need more yes the ultimate complexity of an odd number to check whether it’s prime or not is O (√N).
For finding if the number has any divisors other then 1 and itself it will appear under the square root of N, we don’t need to check up to N.

Java implementation of this method is,

public static boolean IsPrime(long num) {
      if(num < 2)
          return false;

     if(num == 2)
       	return true;

      if( (num & 1) == 0)  // the number is even    
          return false;
      long sqrt = (int) Math.sqrt(num); 
      for(int i = 3; i <= sqrt; i += 2) {
          if(num % i == 0)
             return false;
    return true;  

S. Mahbub – Uz – Zaman
Tuesday, September 13, 2011