update incoming messages in my messageapp automatically
<p>For that, I am writing following code:</p>

<pre><code>    arrayList = new ArrayList&lt;Messagegetter&gt;();
    smsListView = (ListView) findViewById(R.id.listView);
    o = new Messagegetter();
    if(number!=null &amp;&amp; msgNew!=null){
        o.setMsg(msgNew);
        o.setSender(number);
        arrayList.add(o);
        customAdapter = new MessageAdapter(getBaseContext(), R.layout.sms_list, arrayList);
        customAdapter.notifyDataSetChanged();
        smsListView.setAdapter(customAdapter);
    }
</code></pre>

<p>And also created a different class <strong>extending</strong> <code>broadcastReceiver</code> class for receiving new messages.Following is the code:</p>

<pre><code> public class SmsReceiver extends BroadcastReceiver{
@Override
public void onReceive(Context context, Intent intent) 
{       
    Bundle bundle = intent.getExtras();        
    SmsMessage[] msgs = null;
    String str = "";            
    if (bundle != null)
    {   
        Object[] pdus = (Object[]) bundle.get("pdus");
        msgs = new SmsMessage[pdus.length];            
        for (int i=0; i&lt;msgs.length; i++){
            msgs[i] = SmsMessage.createFromPdu((byte[])pdus[i]);                
            String sender= msgs[i].getOriginatingAddress();                     
            str = msgs[i].getMessageBody().toString(); 
            intent1 = new Intent(context, MainActivity.class);
            intent1.putExtra("body", str);
            intent1.putExtra("sender", sender);
            //i.putExtra("sentbody", msg);
            intent1.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
            context.startActivity(intent1);
        }
        //---display the new SMS message---
        Toast.makeText(context, str, Toast.LENGTH_SHORT).show();
    }                         
}
</code></pre>

<p>But I am unable to update my <code>listView</code>. Please help me out.</p>
