I have code which is supposed to answer the phone and hang up right away when someone calls the phone. I get no errors and no force close when the call comes in from a diffe
I don't think you want to do telephonyService.endCall() in getTeleService(). You probably want to call that within the onReceive method instead.
I'm not sure whether you want to reject all calls or only ones from certain numbers. If you are trying to only reject certain numbers, it looks like you don't have any code to check the number of the incoming call against the blocked numbers after retrieving it here:
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
--->// Additional Step <---
--->// Check whether this number matches with your defined Block List <---
--->// If yes, Reject the Call <---
}
You can try changing it to the following if you want to check the number and reject calls only from the blocked numbers:
public void onReceive(Context context, Intent intent) {
Bundle b = intent.getExtras();
incommingNumber = b.getString(TelephonyManager.EXTRA_INCOMING_NUMBER);
// Additional Step
// Check whether this number matches with your defined Block List
// If yes, Reject the Call
for (int i=0; i
Or if you just want to reject all calls, it's even simpler:
public void onReceive(Context context, Intent intent) {
telephonyService.endCall();
}