我正在设计一个自定义呼叫屏幕,以便在通话过程中在屏幕上显示信息,例如来电者的地址簿信息。
我的应用程序将在用户使用Intent Filter
按下呼叫按钮时开始,之后我将从地址簿中提取其他信息并将其添加到屏幕上。
我的问题是,当按下通话按钮时,我的activity
没有启动。我的意图过滤器是对的吗?甚至可以拦截电话Intent
?请分享您处理电话会议的知识。
我的Intent Filter
如下所示。
<activity android:name=".MyCallingScreen">
<intent-filter android:priority="100">
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
</activity>
答案 0 :(得分:4)
在您的情况下,请尝试按照以下方式更改您的代码:
<intent-filter android:priority="100">
<action android:name="android.intent.action.CALL_BUTTON" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
如果按下通话按钮,这对我有用。
尝试使用以下代码拦截来电:
<activity>
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
对于HTC来说有些变化:
<activity>
<intent-filter>
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="vnd.android.cursor.item/phone" />
<data android:mimeType="vnd.android.cursor.item/phone_v2" />
<data android:mimeType="vnd.android.cursor.item/person" />
</intent-filter>
</activity>
当您通过以下方式从电话簿拨打电话时,会调用 android.intent.action.CALL_PRIVILEGED 的意图:电话簿 - >联系人 - >电话号码长按 - &gt;从下拉菜单中选择拨打电话。
答案 1 :(得分:0)
我不确定是否可以更换呼叫屏幕,但拦截任何拨出呼叫都相对简单。你在你的清单中声明一个接收者:
<receiver android:name="com.mystuff.CallInterceptor" android:exported="true">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
</receiver>
并为此拦截器创建一个Java类:
public class CallInterceptor extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
if (!intent.getAction().equals("android.intent.action.NEW_OUTGOING_CALL"))
{
return;
}
String phoneNumber = intent.getStringExtra(Intent.EXTRA_PHONE_NUMBER);
//do stuff using the number
//assuming you do nothing too bad the call will happen and the regular
//call screen comes up - but you can bring up another activity on top of it
//for example shwing address info
}
}