Search code examples
androidphone-numberphone-call

how to get dialed mobile number in my application?


Possible Duplicate:
launching my app when dialing a number

I would like to get the mobile number from dialer which has dialed by user in my android application.I have implemented an application as follows:

 ((Button)findViewById(R.id.button1)).setOnClickListener(new OnClickListener() {

        @Override
        public void onClick(View v) {
             startActivity(new Intent(Intent.ACTION_DIAL, Uri.parse("tel:")));

        }
    });

from the above code i can open dialer app.If user enter a mobile number and click for call then i would like to get which number he has typed. please any body help on it...


Solution

  • I got my solution as following code

    public class OutGoingCall extends BroadcastReceiver {
    
       @Override
       public void onReceive(final Context context, final Intent intent) 
       {
             // get phone number from bundle
             String phoneNumber = intent.getExtras().getString(OutGoingCall.INTENT_PHONE_NUMBER);
    
       }
    }