[英]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.