cordova 如何避免我的混合应用程序显示在Android拨号程序上?

fnatzsnv  于 2022-11-15  发布在  Android
关注(0)|答案(1)|浏览(136)

我为Android和iOS构建了一个呼叫应用程序,我使用Callkit作为呼叫接口。
这是一个混合应用程序开发与离子和 cordova 。
我的问题是,在一些安卓设备(并非全部)中,当用户想通过SIM卡呼叫某人时,我的应用程序会显示出来(作为一个选项),我不希望这种情况发生。
我试着通过手机设置修复它,我可以做到这一点,但只要我进入我的应用程序,它再次发生至今。
这是我正在使用的插件的分支:
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不会显示。
有人能给我们点提示吗?
谢谢你博尔哈。

f45qwnt8

f45qwnt81#

我找到了解决办法:
显然,它是CAPABILITY_CALL_PROVIDER,注册我的应用程序能够从电话堆栈中调用的那个。
让我复制一下我从Googles PhoneAccount类中找到的代码:

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_CALL_PROVIDER,而是CAPABILITY_CONNECTION_MANAGER。行为相同,但我的应用不再显示为电话堆栈中的有效呼叫应用。

相关问题