私はandroid.intent.action.NEW_OUTGOING_CALLを捕まえるためのインテントフィルターを備えたBroadcastreceiverを持っています。Android受信者はNEW_OUTGOING_CALLを無視します
私は多くのチュートリアルを読んで、NEW_OUTGOING_CALLインテントを処理する方法についてここで答えていますが、このことは機能しませんでした。 私の目標は、ブロードキャスト受信者が受信したandroid.intent.action.NEW_OUTGOING_CALLのインテントを記録することです。私はこの単純なことを働かせることができません。
ここに私のコードだ:
たManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.vannus.broadcasttest">
<uses-permission android:name="android.permission.PROCESS_OUTGOING_CALLS" />
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver android:name=".TestReceiver">
<intent-filter>
<action android:name="android.intent.action.NEW_OUTGOING_CALL" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
</application>
</manifest>
これは、プロジェクトもなしで空MainActivityが含まれていBroadcastreceiver(TestReceiver.java)
package net.vannus.broadcasttest;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;
public class TestReceiver extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent)
{
Log.w("###TEST###",intent.getAction());
}
}
のコードです機能性。 プロジェクトを実行するとメインアクティビティが起動しますが、コールを発信または受信しようとするとログは書き込まれません。 エミュレータ(Android 7)とMotorola G4電話(Android 6.0)でコードをテストしましたが、logcatには何も記録されませんでした。 Androidスタジオ2.3を使用しています
私は間違っていますか?
おかげ>アプリを選択したアプリケーションを設定 - と電話許可を与えるために行くの携帯電話に
Vannus