Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android to call from a virtual number

Is it possible to hide the number you are calling from through Android's SDK? Consider this: You wish to make a private call, but since many people block private numbers, you do not want to use *67. This is something Doctors do regularly - they call from their cell phones but do not want the patient to have their private cell numbers.

So imagine we are building an app for Physicians. The app is given a list of contacts, a contact is clicked and the call is made, but in a way that hides the caller ID of this phone. For example, I have a Google Voice number that is different than my real cell phone number and I can receive calls on this number. Is there a way to programmatically make a phone call through Google Voice?

Can I also register some event listener on the call so that when the call is over the app is aware of it?

like image 952
Thorn Avatar asked Nov 04 '22 01:11

Thorn


1 Answers

You can check this link, which uses the telephony api for this. Please check section 15.1.3 Example: Determining the State of a Call.

I am pasting the example code also here:

private class ListenToPhoneState extends PhoneStateListener {

public void onCallStateChanged(int state, String incomingNumber) {
    Log.i("telephony-example", "State changed: " + stateName(state));
}

String stateName(int state) {
    switch (state) {
        case TelephonyManager.CALL_STATE_IDLE: return "Idle";
        case TelephonyManager.CALL_STATE_OFFHOOK: return "Off hook";
        case TelephonyManager.CALL_STATE_RINGING: return "Ringing";
    }
    return Integer.toString(state);
    }
}
like image 191
noob Avatar answered Nov 11 '22 12:11

noob