意图过滤器的android.intent.action.CALL [英] Intent Filter for android.intent.action.CALL

查看:263
本文介绍了意图过滤器的android.intent.action.CALL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个意图过滤器,看起来像这样:

I have an intent filter that looks like so:

<activity
    android:name="com.test.Call"
    android:label="@string/makeCall" >
    <intent-filter>
        <action android:name="android.intent.action.CALL" />
        <category android:name="android.intent.category.DEFAULT" />
        <action android:name="android.intent.action.CALL_PRIVILEGED" />
        <data android:scheme="tel" />
    </intent-filter>
</activity>

这工作正常,当您试图拨打电话我的文字出现的选项之一。我想要做的就是处理一些被称为并询问用户一些问题,然后继续通话。我这样做,通过运行以下code后,我做任何处理我就做的:

This works fine and when you try to make a call my text appears as one of the options. What I want to do is process the number being called and ask the user some questions and then continue on with the call. I do this by running the following code after I do whatever processing I have do do:

Uri phoneCall = Uri.parse("tel:"  + numToCall);
Intent caller = new Intent(Intent.ACTION_DIAL, phoneCall);
startActivity(caller);

问题是,它显示的是从重新开始相同的选项(本地主叫和我的意图过滤器)。这不是我想要的,我想绕过我的意图过滤器,并直接进入本地主叫方。有没有办法做到这一点?我怎样才能迫使意图直接进入本地来电?我在看这个移动的广播接收器,但宁愿走这条路线。

The issue is, it is displaying the same options from the beginning again (the native caller and my intent filter). This is not what I want, I want to bypass my intent filter and go directly to the native caller. Is there a way to do this? How can I force the intent to go directly to the native caller? I am looking at moving this to a broadcast receiver but would rather go this route.

感谢

推荐答案

您可以尝试通过PackageManager.setComponentEnabledSetting(禁用组件)使用DONT_KILL_APP标志!],但你需要重新启用前再次部件下一个电话。

You could try disabling your component via PackageManager.setComponentEnabledSetting() [use the DONT_KILL_APP flags!], but you'll need to re-enable the component again before the next call.

或者你也可以拿黄的上述评论,但发现,赶上ACTION_CALL意图部件和建立你自己的选择器,如果有一个以上的其他比你 - 。使用PackageManager.queryIntentActivities()来获取活动列表

Or you could take Huang's comment above but find out components that catch the ACTION_CALL intent and build your own chooser if there's more than one other than you - use PackageManager.queryIntentActivities() to get a list of Activities.

使用广播确实是正确的道路要走。

Using the broadcast is really the right way to go.

这篇关于意图过滤器的android.intent.action.CALL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆