【发布时间】:2020-12-29 06:00:43
【问题描述】:
是否可以打电话给某人,当没有人接听时,下一个联系人会被调用? 我正在尝试编写这样的应用程序,我阅读了Build a calling app,但它甚至无法使用自定义 UI 进行正常调用。我很沮丧。
【问题讨论】:
标签: java android android-phone-call
是否可以打电话给某人,当没有人接听时,下一个联系人会被调用? 我正在尝试编写这样的应用程序,我阅读了Build a calling app,但它甚至无法使用自定义 UI 进行正常调用。我很沮丧。
【问题讨论】:
标签: java android android-phone-call
您需要获取电话状态,下面的代码将为您提供帮助。
PhoneStateChangeListener pscl = new PhoneStateChangeListener();
TelephonyManager tm = (TelephonyManager)this.getSystemService(Context.TELEPHONY_SERVICE);
tm.listen(pscl, PhoneStateListener.LISTEN_CALL_STATE);
状态结束后,如果未接听,您可以在内部触发下一个呼叫。
更多手机状态监听请查看here
下面的代码是一个使用普通方式缩进调用一个数字的例子。
Intent intent = new Intent(Intent.ACTION_CALL);
intent.setData(Uri.parse("tel:" + bundle.getString("mobilePhone")));
context.startActivity(intent);
别忘了添加通话权限
android.permission.CALL_PHONE
【讨论】: