I am trying to create an application that will perform different functions when a call is received. To make a small working example, I have made my class extend BroadcastReceiver
and I have tried to get a toast notification to show up.
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.widget.Toast;
public class IncomingCallInterceptor extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
Toast.makeText(context, "Do something.", Toast.LENGTH_LONG).show();
}
}
I have added this permission in my AndroidManifest.xml
file:
<application android:icon="@drawable/icon" android:label="Incoming Call Interceptor">
<receiver android:name="IncomingCallInterceptor">
<intent-filter>
<action android:name="android.intent.action.PHONE_STATE"/>
</intent-filter>
</receiver>
</application>
My test device is running Android 4.4.2. No toast notification ever shows up when someone is calling in.