2

I have a application for calling an API for phone call, When a user dials a number from default dialer of android phone, the number should be copied into the second app(free call twilio),shown in picture.

enter image description here

Here is what I tried, but no luck.

<activity
android:name=".MainActivity"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.CALL_BUTTON" />

<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
</activity>

Can anyone help please? :-)

Amy
  • 4,034
  • 1
  • 20
  • 34

4 Answers4

0

please use below code

Register a BroadcastReceiver like this in Manifest file:

    <!-- DIAL Receiver -->
    <receiver
        android:exported="true"
        android:name="receivers.DialBroadcastReceiver" >
        <intent-filter >
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
        </intent-filter>
    </receiver>

You need Permission for NEW_OUTGOING_CALL :

<!-- OUTGOING CALL PERMISSION-->
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />

public class DialBroadcastReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

    Log.v("DileBroadCastReceiver","In onReceive()");

    if (intent.getAction().equals(Intent.ACTION_NEW_OUTGOING_CALL)) {
         String number = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

         Log.v("DialBroadcast Receiver","Number is: "+number);

    }

  }
}
Sanket Kachhela
  • 10,861
  • 8
  • 50
  • 75
0

I think you forgot to add intent-filter in your mainActivty like below

       <intent-filter>
            <action android:name="android.intent.action.MAIN" />

            <category android:name="android.intent.category.LAUNCHER" />
      </intent-filter>

also add your existing intent-filter as well. Gud luck

maddy d
  • 1,530
  • 2
  • 12
  • 23
0

It can be possible after searching a lot in google. Finally I got an answer I am sharing it for others.

It can be possible by adding following intent filter in manifest file.

  <intent-filter>
        <action android:name="android.intent.action.CALL_BUTTON" />
        <category android:name="android.intent.category.DEFAULT" />
  </intent-filter>
Amy
  • 4,034
  • 1
  • 20
  • 34
-1

create a broadcast reciever with android.intent.action.NEW_OUTGOING_CALL and then call dialledNumber=intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);

This will give you outgoing number

try this.it might help

Intent callIntent = new Intent(Intent.ACTION_CALL, Uri.parse("tel:" + phoneNumber));
callIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);    
context.startActivity(callIntent);
vs.thaakur
  • 619
  • 3
  • 13
  • I want to make call from my application. Your suggested answer is for read number after making call from SIM card. – Amy Mar 13 '14 at 10:31
  • I think you should call the default application for making call for you. – vs.thaakur Mar 13 '14 at 10:48
  • Yes I am calling my application but cant able to pass dialed number to that application – Amy Mar 13 '14 at 11:36
  • the edit if for passing the number from your application to the default application – vs.thaakur Mar 13 '14 at 11:54
  • Actually I want pass number dialpad to my App. and you suggest me exactly reverse solution. – Amy Mar 13 '14 at 12:01
  • http://stackoverflow.com/questions/8267411/make-or-receive-call-secretly-programmatically-android check this link. – vs.thaakur Mar 13 '14 at 12:22
  • I think you are not getting my question. I dont want to call problematically. I have to show dialed number after choose default app i.e. free call twilio (shown in Image) – Amy Mar 13 '14 at 12:40
  • sorry I wont be able to answer that.Sorry for wasting your time – vs.thaakur Mar 13 '14 at 12:58