Is it possible to call someone and when no ones answer the next contact will be called?

50 views Asked by At

Is it possible to call someone and when no ones answer the next contact will be called? I am tryin to code such an app, I read Build a calling app, but it do not understand even to make a normal call with a custom UI. I'm frustrated.

1

There are 1 answers

2
Pranav MS On

You need to get phone call state the below piece of code will help you.

PhoneStateChangeListener pscl = new PhoneStateChangeListener();
TelephonyManager tm = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(pscl, PhoneStateListener.LISTEN_CALL_STATE);

After the state you can internally trigger next call if it is not answered .

for more phone state listener please view here

The below code is an example for call a number by indent using normal way.

Intent intent = new Intent(Intent.ACTION_CALL);

intent.setData(Uri.parse("tel:" + bundle.getString("mobilePhone")));
context.startActivity(intent);

dont forget to add the permission to do the call

android.permission.CALL_PHONE