如何避免我的混合应用程序出现在 Android 拨号器上?

How can I avoid having my hybrid app showing up on the Android dialer?

我为 Android 和 iOS 构建了一个调用应用程序,我正在使用 Callkit 作为调用界面。

这是一款使用 Ionic 和 Cordova 开发的混合应用程序。

我的问题是,在某些 android 设备(并非全部)中,当用户想要通过 SIM 卡呼叫某人时,我的应用会出现(作为一个选项)。我不希望发生这种情况。

我尝试通过 phone 设置修复它,我可以完成它,但是一旦我进入我的应用程序,它就会再次发生。

这是我正在使用的插件的分支:

https://github.com/Qvadis/cordova-plugin-callkit

我做了一些研究,我发现这可能与这段代码有关:

if(android.os.Build.VERSION.SDK_INT >= 23) {
    phoneAccount = new PhoneAccount.Builder(handle, appName)
               .setCapabilities(PhoneAccount.CAPABILITY_CALL_PROVIDER)
               .build();
    tm.registerPhoneAccount(phoneAccount);
 }

但是,如果我评论它,callkit UI 不会显示。

任何人都可以在这里阐明一些问题吗?

谢谢, 博尔哈

我找到了解决方案:

显然是 CAPABILITY_CALL_PROVIDER,那个正在注册我的应用程序的人能够从电话堆栈中调用。

让我复制我从 googles PhoneAccount class 中找到的代码:

public class PhoneAccount implements Parcelable {
/**
 * Flag indicating that this {@code PhoneAccount} can act as a connection manager for
 * other connections. The {@link ConnectionService} associated with this {@code PhoneAccount}
 * will be allowed to manage phone calls including using its own proprietary phone-call
 * implementation (like VoIP calling) to make calls instead of the telephony stack.
 * <p>
 * When a user opts to place a call using the SIM-based telephony stack, the
 * {@link ConnectionService} associated with this {@code PhoneAccount} will be attempted first
 * if the user has explicitly selected it to be used as the default connection manager.
 * <p>
 * See {@link #getCapabilities}
 */
public static final int CAPABILITY_CONNECTION_MANAGER = 0x1;
/**
 * Flag indicating that this {@code PhoneAccount} can make phone calls in place of
 * traditional SIM-based telephony calls. This account will be treated as a distinct method
 * for placing calls alongside the traditional SIM-based telephony stack. This flag is
 * distinct from {@link #CAPABILITY_CONNECTION_MANAGER} in that it is not allowed to manage
 * calls from or use the built-in telephony stack to place its calls.
 * <p>
 * See {@link #getCapabilities}
 * <p>
 * {@hide}
 */
public static final int CAPABILITY_CALL_PROVIDER = 0x2;

我使用的是 CAPABILITY_CONNECTION_MANAGER,而不是 CAPABILITY_CALL_PROVIDER。相同的行为,但我的应用程序不再显示为电话堆栈中的有效调用应用程序。