如何获取我拨打的人的电话号码

时间:2011-06-17 15:34:34

标签: android

在Android中,我需要获取我在BroadcastReceiver中拨打的人的电话号码(OFFHOOK状态)

我知道我可以获得INCOMING号码,但我需要传出,是否可能?

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:1)

您可以从广播中检索此内容以响应ACTION_NEW_OUTGOING_CALL:

public class CallReceiver extends BroadcastReceiver {
  @Override
  public void onReceive(Context context, Intent intent) {
    // Try to read the phone number from previous receivers.
    String phoneNumber = getResultData();

    if (phoneNumber == null) {
      // We could not find any previous data. Use the original phone number in this case.
      phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
    }

  }
}

may not be the only broadcast receiver处理电话号码时使用getResultData非常重要。