Basically what I'm trying to do is when I change the sim in my phone I want to send a message to a number that my sim has been changed. Here's my manifest: I have added the permission to send sms and intent to track the sim change
<uses-permission android:name="android.permission.SEND_SMS" />
   <receiver android:name=".SimChangeReceiver">
            <intent-filter>
                <action android:name="android.intent.action.SIM_STATE_CHANGED"/>
            </intent-filter>
        </receiver>
Here's the broadcast receiver I used.
public class SimChangeReceiver extends BroadcastReceiver {
    @Override
    public void onReceive(Context context, Intent intent) {
        Toast.makeText(context, "SIM state changed", Toast.LENGTH_SHORT).show();
        SmsManager smsmanager=SmsManager.getDefault();
        smsmanager.sendTextMessage(mynumber,null,"sim has been changed",null,null);
    }
}
The problem is when I change the sim, the Toast happens couple of times and the message gets send 4 times exactly to mynumber. Why is it happening? Can I put some limit to it to just send the message only once? I'm new to Android. So forgive me if I can't find the problem.