私はBroadcastReceiverを作成してCALLアクションを検出しました。android - BroadcastReceiverでCALLインテントを受信できません
android.intent.action.CALL
アクティビティで宣言されたときに、インテントが受信されます。
<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>
しかし、それはBroadcastReceiverまたはサービス上では動作しません。
のAndroidManifest.xml
<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>
PhoneCallListener.java
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();
}
}
}
ください、あなたのアプリケーションのアクセス許可を記載してください – eduyayo