How can I add my application to the android default Dialer selection?

你说的曾经没有我的故事 提交于 2019-12-18 18:05:31

问题


My Question is how can I add my application to the android default Dialer selection, to be more specific without using the android.intent.action.CALL_PRIVILEGED?

Now I am using this code below, this works fine:

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

HOWEVER Google recently posted: http://productforums.google.com/forum/#!topic/mobile/wXqnbynsL8Y

And mailed this to the programmes who does use the intent android.intent.action.CALL_PRIVILEGED:

Issue: Users of your application may not be able to make emergency phone calls through the system phone dialer if they've elected to have your application route calls. As noted in the documentation, applications that listen for the CALL_PRIVILEGED Intent action will intercept emergency service calls from the system, but may not be able to route them properly. Please note that CALL_PRIVILEGED is a restricted API, not intended for use within third party applications that cannot route emergency calls properly.

Solution:
• Remove CALL_PRIVILEGED from Intent filters in Java code and AndroidManifest.xml. • Update your Google Play listing description to include a statement that using your app as a default dialer may interfere with dialing 911 emergency services.

The easiest solution my be deleting but then the application would use functionality. But is there another way to add the application to the default Dialer selection? but then without the CALL_PRIVILEGED intent?

Thanks in advance

Just an example of the default Dialer selection

Edit:

My other intents that I use:

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

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

回答1:


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

More important is that privileged call action is needed in intent filter with data as "tel" for uri. Also below permission tag is need to allow phone call. Missing in your code in category Launcher.

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



回答2:


You don't need to intercept CALL_PRIVILEGED to make a dialer. There are 3 intents of interest:

ACTION_DIAL: invokes the dialer. You should intercept this.

CALL: places a call. I suppose you need to intercept this if you are routing the call via VoIP, else just pass it on to the system.

CALL_PRIVILEGED: places an Emergency call (911 in US etc). You don't need to intercept this, since these calls are routed specially, even without a SIM card, and without charging the user.

For what it's worth, I got the same email from Google. My app doesn't even use CALL or CALL_PRIVILEGED intents. There was however, a check in the code that the passed intent was not this action (just for the sake of completeness). So, I think they just scan the data section of the apk to see if this string is used anywhere.

Edit try this, it works for my app:

    <activity android:name=".ActivityName"
              android:label="@string/activity_name">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <action android:name="android.intent.action.DIAL" />
            <action android:name="android.intent.action.CALL_BUTTON" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>

    <activity-alias android:targetActivity="fully.qualified.ActivityName"
                    android:name="fully.qualified.ActivityName_HTC_hack"
                    android:exported="true">
        <intent-filter>
            <action android:name="android.intent.action.VIEW" />
            <action android:name="android.intent.action.DIAL" />
            <data android:scheme="tel" />
            <category android:name="android.intent.category.DEFAULT" />
            <category android:name="android.intent.category.BROWSABLE" />
        </intent-filter>
    </activity-alias>



回答3:


Try "android.intent.action.DIAL". The user has to start the call manually, but i think it's the best solution.

Input: If nothing, an empty dialer is started; else getData() is URI of a phone number to be dialed or a tel: URI of an explicit phone number. ref: developer page



来源:https://stackoverflow.com/questions/16587026/how-can-i-add-my-application-to-the-android-default-dialer-selection

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!