I have an app that listens for incoming calls and depending upon the number sends an SMS to that number. Everything is working on incoming the onReceive
is called and SMS is sent but as soon as the call is rejected either by called or caller party onReceive
is called again and SMS is sent again. How can I limit this, so when a call is received only then the onReceive
is called?
Following is the simple version of my code:
My BroadcastReceiver
import android.content.BroadcastReceiver; import android.content.Context; import android.content.Intent; import android.util.Log;
public class Telephone extends BroadcastReceiver {
@Override
public void onReceive(Context arg0, Intent arg1) {
// TODO Auto-generated method stub
Log.d("onReceive", "Got Call Signal");
}
}
in Manifest:
<receiver android:name="com.example.testbroadcastreceiver.Telephone" >
<intent-filter android:priority="1000" >
<action android:name="android.intent.action.PHONE_STATE" />
</intent-filter>
</receiver>
Permission used:
<uses-permission android:name="android.permission.READ_PHONE_STATE"/>