title: Updating a listview in Fragment
body: <p>I'm fairly new to programming for android and programming in general. I searched the web and stackoverflow for a solution, but can't seem to find one.</p>
  
  <p>I have an app with different tabs handled in fragments. One of my fragments contains a listview. However, the listview won't updat or refresh. It should refresh when I get an incoming sms. Here is the fragment code:</p>
  
  <pre><code>public class SmsSectionFragment extends Fragment {
  
      @SuppressWarnings("null")
      @Override
      public View onCreateView(LayoutInflater inflater, ViewGroup container,
              Bundle savedInstanceState) {
          View listView = inflater.inflate(R.layout.fragment_section_sms, container, false);
  
          ListView mListData = (ListView) listView.findViewById(R.id.lvData);
          TextView aantalSms = (TextView) listView.findViewById(R.id.aantalSms);
  
          ArrayList&lt;SmsInfo&gt; listSms = getIntent().getParcelableArrayListExtra("ListSMS");
  
          // check condition 
          if(listSms != null &amp;&amp; listSms.size() &gt; 0) {
                  // set data to list
                  SmsInfoAdapter adapter = new SmsInfoAdapter(getActivity(), listSms);
                  mListData.setAdapter(adapter);
                  adapter.setNotifyOnChange(true);
                  int count = listSms.size();
                  aantalSms.setText(String.valueOf(count));
  
          }
  
          return listView;
      }
  </code></pre>
  
  <p>The receiving of sms is handled in three other classes, the Receiver code is:</p>
  
  <pre><code>package com.example.android.effectivenavigation;
  </code></pre>
  
  <p>import... etc</p>
  
  <pre><code>public class SmsReceiver extends BroadcastReceiver {
  
  static ArrayList&lt;SmsInfo&gt; listSms = new ArrayList&lt;SmsInfo&gt;();
  @Override
  public void onReceive(Context context, Intent intent) {
  
  
  
      // get SMS map from intent
      Bundle extras = intent.getExtras();
      // a notification message
      String messages = "";
      if ( extras != null ) {
          // get array data from SMS
          Object[] smsExtra = (Object[]) extras.get( "pdus" ); // "pdus" is the key
  
          for ( int i = 0; i &lt; smsExtra.length; ++i ) {
              // get sms message
              SmsMessage sms = SmsMessage.createFromPdu((byte[])smsExtra[i]);
              // get content and number
              String body = sms.getMessageBody();
              String adition = "  SMS::  ";
              String einde = " ::SMS";
              String sendme = adition + body + einde;
              String address = sms.getOriginatingAddress();
              // create display message
              messages += "SMS from " + address + " :\n";
              messages += body + "\n";
  
  
              //Send to Arduino
              Amarino.sendDataToArduino(context, DEVICE_ADDRESS, 'T', sendme);
  
  
              // store in the list
              listSms.add(new SmsInfo(address, body));
          }
  
          // better check size before continue
          if(listSms.size() &gt; 0) {
              // notify new arriving message
              //Toast.makeText( context, messages, Toast.LENGTH_SHORT ).show();
              // set data to send
              Intent data = new Intent(context, MainActivity.class);
              // new activity
              data.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
  
              data.putParcelableArrayListExtra("ListSMS", listSms);
              // start
              context.startActivity(data);
  
  
          }
      }
  }
  </code></pre>
  
  <p>Could someone shine some light on my problem?
  Many thanks in advance!</p>