简体   繁体   中英

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

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

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>

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM