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

泄露秘密 提交于 2019-11-30 16:26:54
         <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

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