Hi Guys,
I want to do a call forwarding to a particular number using the
following code
The issue is I get a ring from a number but it dosen't get forwarded
automatically
to the desired number (<phone_number>). After the call ends the dialer
gets popped with the desired number which had to be automatically
called
(which is the intended call forwarding number)
number **21*+<phone_number>+**2#
What am I missing.
Thanks a Ton
public class dialing extends Activity {
ListenToPhoneState listener;
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
call();
}
private void call() {
TelephonyManager tManager = (TelephonyManager)
getSystemService(Context.TELEPHONY_SERVICE);
listener = new ListenToPhoneState();
tManager.listen(listener,
PhoneStateListener.LISTEN_CALL_STATE);
}
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:
String encodedHash = Uri.encode("#");
Log.e("telephony-example", "before call
forward");
startActivity(new Intent
("android.intent.action.DIAL",
Uri.parse("tel:**21*+<phone_number>+**2"
+
encodedHash)));
return "Ringing";
}
return Integer.toString(state);
}
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---