-1

There's an application with a button that when pressed is using the startActivity method with the ACTION_CALL intent.

This is how its called:

public void call(String number)
{
    Intent myIntent = new Intent(Intent.ACTION_CALL);
    myIntent.setData(Uri.parse("tel:" + number);
    startActivity(myIntent);
}

I have made a dialer app with the permission:

<uses-permission android:name="android.permission.CALL_PHONE" />

And my manifest looks like this:

 <intent-filter>
    <action android:name="android.intent.action.MAIN" />
    <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
 <intent-filter>
    <action android:name="android.intent.action.VIEW" />
    <action android:name="android.intent.action.DIAL" />
    <category android:name="android.intent.category.DEFAULT" />
    <category android:name="android.intent.category.BROWSABLE" />
    <data android:scheme="tel" />
</intent-filter>
<intent-filter>
    <action android:name="android.intent.action.CALL_BUTTON" />
    <category android:name="android.intent.category.DEFAULT" />
</intent-filter>

Every other question I've seen is suggesting this exact declarations to be made in the manifest.

I've checked and there are no defaults set on the Google dialer app which comes with the phone.

So why won't a pop up dialog show with an option to choose my application as the dialer to catch that intent?

JJ Ab
  • 492
  • 4
  • 15
  • what problem you are facing.? – Swaminathan V Jun 07 '16 at 12:13
  • What I wrote in the question: why won't a pop up dialog show with an option to choose my application as the dialer to catch that intent? – JJ Ab Jun 07 '16 at 12:28
  • can you share you android code for calling ? that might be helpful – Swaminathan V Jun 07 '16 at 12:45
  • @RaguSwaminathan I've edited and added the code – JJ Ab Jun 07 '16 at 14:06
  • @RaguSwaminathan so do you have any idea why is it not working? – JJ Ab Jun 08 '16 at 05:55
  • do you want to trigger a call from your app using the above code? correct ? – Swaminathan V Jun 08 '16 at 06:06
  • The above code is triggering a call which is supposed to be intercepted by my second application which Is the dialer application who knows how to handle this kind of calls. Right now the default Google dialer which came with the phone is automatically opens, and I want to avoid it, and let the use choose if he wants to use the default Android dialer or my dialer application. – JJ Ab Jun 08 '16 at 06:12
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/114091/discussion-between-ragu-swaminathan-and-jj-ab). – Swaminathan V Jun 08 '16 at 06:20

1 Answers1

1

I have finally got it to work. After adding a bunch of intent filters it started working:

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

            <action android:name="android.intent.action.CALL" />
            <action android:name="android.intent.action.CALL_BUTTON" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="tel" />

        </intent-filter>

        <intent-filter android:priority="100" >

            <action android:name="android.intent.action.DIAL" />
            <category android:name="android.intent.category.DEFAULT" />
            <data android:scheme="tel" />

        </intent-filter>

        <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>

        <intent-filter>

            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.DIAL" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
            <data android:scheme="tel" />

        </intent-filter>

I think the first one did the magic.

JJ Ab
  • 492
  • 4
  • 15