android Log.d and Toast showing strange behavior
<p>hi :) i'm in my SMS receiver class, that handles the incomming sms. it normally works fine, but i'm actually trying to block some senders. i placed the blocked numbers in an <strong>ArrayList</strong> named <strong>blackList</strong>. A code segment below shows what i'm doing at end:</p>

<pre><code>    String sender = "";
    boolean allowed = true;
        for(int i=0;i&lt;msgs.length;i++)
        {
            msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);

            sender = msgs[i].getOriginatingAddress();

            if(BlockedNumber.blackList.contains(sender))
            {
                allowed = false;
                break;
            }

            str = "SMS From: " + msgs[i].getOriginatingAddress();
            str += ":";
            str += msgs[i].getMessageBody().toString();
            str += "\n";
        }

        String numm = BlockedNumber.blackList.get(2);
        Toast.makeText(context, numm, Toast.LENGTH_LONG).show();
        Log.d("CHEKK", numm);

        if(allowed == true){

            //.makeText(context, str, Toast.LENGTH_LONG).show();
        }
</code></pre>

<p>but its not works as expected. since i'm trying to display the <strong>numm</strong> named variable in Toast, but it still shows the only one toast, which displays the incoming sms. i've commented it, but it still shows the msg, and doesn't shows the <strong>numm</strong> named variable, which i'm trying to display.
secondly, Log.d is not displaying anything. its really not working.</p>

<p>kindly tell me 2 things:</p>

<ol>
<li>kindly tell me, if there's something wrong? or anything i'm missing?</li>
<li>is my approach to blocking incomming sms from specified number is correct?</li>
</ol>

<p>Thanks!</p>

<p>.......</p>

<p>here's my full SMS Receiver class:</p>

<pre><code>package com.example.pingpongsmsremote;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.telephony.SmsMessage;
import android.util.Log;
import android.widget.Toast;

public class SMSreceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {

    BlockedNumber.blackList.add("Zeeshan");
    Bundle bundle = intent.getExtras();
    String str = "";
    SmsMessage[] msgs = null;

    if(bundle != null)
    {
    Object[] pdus = (Object[]) bundle.get("pdus");
    msgs = new SmsMessage[pdus.length];
    String sender = "";
    boolean allowed = true;
        for(int i=0;i&lt;msgs.length;i++)
        {
            msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);

            sender = msgs[i].getOriginatingAddress();

            if(BlockedNumber.blackList.contains(sender))
            {
                allowed = false;
                break;
            }

            str = "SMS From: " + msgs[i].getOriginatingAddress();
            str += ":";
            str += msgs[i].getMessageBody().toString();
            str += "\n";
        }

        String numm = BlockedNumber.blackList.get(0);
        Toast.makeText(context, numm, Toast.LENGTH_LONG).show();
        Log.d("CHEKK", numm);

        if(allowed == true){

            //.makeText(context, str, Toast.LENGTH_LONG).show();
        }

    }

}

}
</code></pre>
