【问题标题】:Is it possible to call someone and when no ones answer the next contact will be called?是否可以打电话给某人,当没有人接听时,会打电话给下一个联系人?
【发布时间】:2020-12-29 06:00:43
【问题描述】:

是否可以打电话给某人,当没有人接听时,下一个联系人会被调用? 我正在尝试编写这样的应用程序,我阅读了Build a calling app,但它甚至无法使用自定义 UI 进行正常调用。我很沮丧。

【问题讨论】:

    标签: java android android-phone-call


    【解决方案1】:

    您需要获取电话状态,下面的代码将为您提供帮助。

    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
    

    【讨论】:

    • 感谢您的回答。我稍后会尝试。
    • 我觉得它不起作用。没有“未接听”状态,我无法覆盖呼叫。
    猜你喜欢
    • 2012-02-09
    • 2022-06-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-12-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-04
    相关资源
    最近更新 更多