找我打电话在Android上的数 [英] Get the number I am calling in Android
问题描述
我需要,我从我的Android设备编程呼叫的号码。我现在做的是以下内容:
I need to get the number that I am calling from my Android device programmatically. What I'm doing now is the following:
我听 android.intent.action.PHONE_STATE
正在播出这意味着,要么我被称为或正在呼叫(或接收短信等)。
I listen for android.intent.action.PHONE_STATE
being broadcasted which means that either I am being called or am calling (or receiving an SMS etc).
在的BroadcastReceiver
我获取额外的 incoming_number
从意图。可悲的是,我不能让这被称为如果的 I 的数量发起呼叫,但。我怎样才能做到这一点?
In a BroadcastReceiver
I retrieve the extra incoming_number
from the intent. Sadly I cannot get the number which is being called if I initiate the call though. How can I do this?
推荐答案
您需要使用意图 android.intent.action.NEW_OUTGOING_CALL
在这个意图,你可以得到额外的 Intent.EXTRA_PHONE_NUMBER
包含呼出号码。
You need to use the Intent android.intent.action.NEW_OUTGOING_CALL
in this intent you can get the extra Intent.EXTRA_PHONE_NUMBER
which contains the outgoing number.
如果一个新的去话呼叫是intanciated意图发出
The intent is issued if a new outgoing call is intanciated.
您需要的权限 android.permission.PROCESS_OUTGOING_CALLS
这一点。
You will need the Permission android.permission.PROCESS_OUTGOING_CALLS
for this.
希望有所帮助。
这篇关于找我打电话在Android上的数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!