Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
282 views
in Technique[技术] by (71.8m points)

android - Fetch dial number while calling.

When I enter any number in keypad and after when I press call button before the phone make call, I want to get that dial number in logcat.

See below Image for understand.

enter image description here

Can I get the number at the time of calling, if yes then How can I?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Try using these solution.Also refer this

   public class OutgoingCallReceiver extends BroadcastReceiver {

   public static final String ABORT_PHONE_NUMBER = "1231231234";

   private static final String OUTGOING_CALL_ACTION = "android.intent.action.NEW_OUTGOING_CALL";
   private static final String INTENT_PHONE_NUMBER = "android.intent.extra.PHONE_NUMBER";

   @Override
   public void onReceive(final Context context, final Intent intent) {
      Log.v(Constants.LOGTAG, "OutgoingCallReceiver onReceive");
      if (intent.getAction().equals(OutgoingCallReceiver.OUTGOING_CALL_ACTION)) {
         Log.v(Constants.LOGTAG, "OutgoingCallReceiver NEW_OUTGOING_CALL received");

         // get phone number from bundle
         String phoneNumber = intent.getExtras().getString(OutgoingCallReceiver.INTENT_PHONE_NUMBER);
         if ((phoneNumber != null) && phoneNumber.equals(OutgoingCallReceiver.ABORT_PHONE_NUMBER)) {
            Toast.makeText(context, "NEW_OUTGOING_CALL intercepted to number 123-123-1234 - aborting call",
                     Toast.LENGTH_LONG).show();
            this.abortBroadcast();
         }
      }
   }
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...