简体   繁体   English

截接号码

[英]Intercepting number dialed

I don't want to be the default dialer app. 我不想成为默认的拨号器应用程序。

I just want my app to be launched when the users dial a specific number, eg 1234, in the default dialing app. 我只希望在用户拨打默认拨号应用程序中的特定号码(例如1234)时启动我的应用程序。

Is this possible? 这可能吗?

Scenario: an airline has an app to make bookings and provide many customer support functions. 场景:航空公司有一个应用程序可以进行预订并提供许多客户支持功能。 It also has a customer service hotline. 它还有一个客户服务热线。 However, it wants to reduce traffic to the hotline (expensive agents) and hopes to see most requests serviced by the app as far as possible. 但是,它希望减少热线(昂贵的代理商)的访问量,并希望尽可能多地看到该应用程序服务的大多数请求。 So when a user dials the airline hotline number, the airline app (if installed) is launched instead. 因此,当用户拨打航空公司热线号码时,将启动航空公司应用程序(如果已安装)。

Yeah, its possible. 是的,有可能。 Refer to "Listening for outgoing call requests" from here . 请从此处参考“收听去电请求”。

Run your app on phone load. 在电话负载下运行您的应用。 Here's an example broadcast receiver declared in an app's manifest file: 这是在应用清单文件中声明的广播接收器示例:

<manifest>
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />  
<application>
    ...
    <receiver android:name=MyOutgoingCallHandler">
        <intent-filter>
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />
            <category android:name="android.intent.category.DEFAULT" />
        </intent-filter>
    </receiver>
    ...
</application>
</manifest>

The implementation of the corresponding broadcast receiver would look something like this: 相应的广播接收器的实现如下所示:

public class MyOutgoingCallHandler extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
    // Extract phone number reformatted by previous receivers
        String phoneNumber = getResultData();
        if (phoneNumber == null) {
        // No reformatted number, use the original
            phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
        }
        // My app will bring up the call, so cancel the broadcast
        setResultData(null);
        // Start my app to bring up the call
    ...
  }
}

so you can check the number from 这样您就可以从

phoneNumber

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 PhoneStateListener 没有给出拨打/呼叫的号码 - PhoneStateListener not giving the number dialed / called Android:我可以从已拨电话列表中删除已拨电话号码吗? - Android : Can I remove the dialed number from dialed calls list? 确定正在拨打的号码是否在联系人列表中 - Determine if a number being dialed is in the contact list 检测用户是否以编程方式实际拨打了号码 - Detect if the user actually dialed a number programmatically 获取在Android本机拨号器中拨打的号码 - Get number as dialed in the native dialer of Android 如何查看拨打的电话是否忙? - How to check if the dialed number is busy or is not answered? 如何获取正在拨打的号码,Android中的外拨号码 - How to get the number that is being dialed the , the outgoing number in android 检索具有电话号码(如已拨电话号码)的联系人列表 - Retrieve a list of contacts having phone number like the dialed number 如何在未经许可的情况下在我的应用程序中获取拨叫号码 - How to get Dialed number in my Application Without Permission 在Android 9.0中没有获得用户拨打的号码即使我在运行时也声明了读取呼叫日志和REad电话状态权限 - Not getting user dialed number in Android 9.0 Even i have declared both Read call log and REad Phone State permission at Runtime as well
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM