【问题标题】:Android intent action wrong when making an outgoing call拨出电话时Android意图操作错误
【发布时间】:2019-09-12 12:16:28
【问题描述】:

我正在开发一个记录电话信息(电话号码、日期和时间)的 Android (kotlin) 应用程序。它适用于来电,但我无法处理拨出电话。

我尝试了很多解决方案,但似乎都没有奏效。

这是最推荐的一个:

override fun onReceive(context: Context?, intent: Intent?) {
    if(intent?.action.equals(Intent.ACTION_NEW_OUTGOING_CALL))
    {
        //Outgoing call
        String number=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    }
}

当有拨出电话时intent.action 应该是android.intent.action.ACTION_NEW_OUTGOING_CALL,但是当我调试应用程序时,调试器显示actionandroid.intent.action.PHONE_STATE

有没有办法解决这个问题或一些解决方法?

【问题讨论】:

    标签: android kotlin broadcastreceiver action outgoing-call


    【解决方案1】:

    只需尝试android.intent.action.NEW_OUTGOING_CALL 操作即可。

    if (intent?.action == "android.intent.action.NEW_OUTGOING_CALL") {
        // ..
    }
    

    【讨论】:

      猜你喜欢
      • 2020-07-29
      • 1970-01-01
      • 2023-03-04
      • 2011-04-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多