android-无法在BroadcastReceiver中接收呼叫意图
我创建了一个广播接收器,用于检测呼叫操作android-无法在BroadcastReceiver中接收呼叫意图,android,android-intent,broadcastreceiver,action,phone-call,Android,Android Intent,Broadcastreceiver,Action,Phone Call,我创建了一个广播接收器,用于检测呼叫操作 android.intent.action.CALLintent在活动中声明时被接收 <activity android:name="com.xxx.yyy.CallCatcherActivity" android:launchMode="singleTop" android:theme="@android:style/Theme.Translucent.NoTitleBar" android:screenOrien
android.intent.action.CALL
intent在活动中声明时被接收
<activity
android:name="com.xxx.yyy.CallCatcherActivity"
android:launchMode="singleTop"
android:theme="@android:style/Theme.Translucent.NoTitleBar"
android:screenOrientation="landscape">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.CALL" />
<action android:name="android.intent.action.CALL_BUTTON" />
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
</activity>
动作呼叫和动作拨号用于启动
活动
,这些动作不用于广播意图
s。有单独的Intent
s用于启动活动
、服务
和广播接收器
s,它们彼此无关
有关如何捕获意图.操作\u新建\u传出\u呼叫
以及如何使用PhoneStateListener
检测呼叫状态变化的详细信息,请参阅
另请参阅以获取有关检测传入和传出呼叫的教程。请列出您的应用程序权限
<receiver android:name="PhoneCallListener">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.BROWSABLE" />
<action android:name="android.intent.action.CALL" />
<action android:name="android.intent.action.CALL_BUTTON" />
<action android:name="android.intent.action.CALL_PRIVILEGED" />
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
<action android:name="android.intent.action.DIAL" />
<category android:name="android.intent.category.DEFAULT" />
<data android:scheme="tel" />
</intent-filter>
</receiver>
public class PhoneCallListener extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Log.d("-", intent.getAction() + " received");
try {
if (intent.getAction().equals("android.intent.action.CALL")) {
Log.d("-", "+ CALL action received!!");
}
} catch (Exception e) {
e.printStackTrace();
}
}
}