How to get phone number of the person I'm dialing
in Android, I need to get the phone number of the person I'm dialing to in my BroadcastReceiver (OFFHOOK state)
I know I can get the INCOMING number but I need the outgoing, is it possible?开发者_Go百科
See http://code.google.com/p/unlocking-android/source/browse/chapter7/trunk/src/com/msi/manning/telephonyexplorer/OutgoingCallReceiver.java?spec=svn78&r=78
You can retrieve this from a Broadcast in response to 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);
}
}
}
It is important to use getResultData as you may not be the only broadcast receiver processing the phone number.
精彩评论