If we just paste above code to our android program, we will never be able to compile the code. It is because it used some android internal classes "android.os.IBinder", "android.os.ServiceManager" and "com.android.internal.telephony.ITelephony". Those classes is not available in the android SDK. So, I use java reflection to access such classes. Below are the rewrote code: