title: Custom Adapter notifyDataSetChanged()
body: <p>I have studied all the issues related to this problem, but I haven't found a solution.</p>
  
  <p>The project works as follows: I create a customListView (in Main2.clas) from an XML file (http: //.../data.xml) on the web server. A single entry (playStatus) in the XML file is updated every 15 seconds on the web server. I check for updates in this application every 15 seconds (in UpdateXML.class). If data.xml has been updated since creation of customListview, I want to update the entry in cutomListview.</p>
  
  <p>But the following error returns:</p>
  
  <blockquote>
    <p>java.lang.IllegalStateException: System services not available to Activities before onCreate()</p>
  </blockquote>
  
  <p>Main2.class</p>
  
  <pre><code>    public class Main2 extends Activity {
      int playStatus;
      String Adi,online ,Logo ,msUrlx ;
      public int ax;
      ArrayList&lt;String&gt; onlineKontrol;
      public ListView defaultList;
  
      @Override
      public void onCreate(Bundle savedInstanceState) {
          setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
          super.onCreate(savedInstanceState);
          setContentView(R.layout.main2);
  
          StrictMode.ThreadPolicy policy = new StrictMode.ThreadPolicy.Builder().permitAll().build();
          StrictMode.setThreadPolicy(policy);
  
  
          defaultList = (ListView) findViewById(R.id.listview5);
          CustomAdapter myAdapter = new CustomAdapter(this,MainListOlustur());
          defaultList.setAdapter(myAdapter);
  
  
          UpdateXML guncelle = new UpdateXML();
          guncelle.execute();
  
      }
  
          public ArrayList&lt;MainList&gt; MainListOlustur(){
  
              ArrayList&lt;MainList&gt; defaultList = new ArrayList&lt;MainList&gt;();
              try {
  
                  URL url = new URL("http://.../data.xml");
                  DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
                  DocumentBuilder db = dbf.newDocumentBuilder();
                  Document doc = db.parse(new InputSource(url.openStream()));
                  doc.getDocumentElement().normalize();
  
                  NodeList nodeList = doc.getElementsByTagName("kanal");
  
  
                  for (int i = 0; i &lt; nodeList.getLength(); i++) {
  
                      Node node = nodeList.item(i);
  
  
                      Element fstElmnt = (Element) node;
                      NodeList adiList = fstElmnt.getElementsByTagName("adi");
                      Element adiElement = (Element) adiList.item(0);
                      adiList = adiElement.getChildNodes();
  
                      NodeList logoList = fstElmnt.getElementsByTagName("logo");
                      Element logoElement = (Element) logoList.item(0);
                      logoList = logoElement.getChildNodes();
  
                      NodeList msUrlList = fstElmnt.getElementsByTagName("msurl");
                      Element msUrlElement = (Element) msUrlList.item(0);
                      msUrlList = msUrlElement.getChildNodes();
  
  
                      NodeList onlineList = fstElmnt.getElementsByTagName("online");
                      Element onlineElement = (Element) onlineList.item(0);
                      onlineList = onlineElement.getChildNodes();
  
                      NodeList playStatusList = fstElmnt.getElementsByTagName("playStatus");
                      Element playStatusElement = (Element) playStatusList.item(0);
                      playStatusList = playStatusElement.getChildNodes();
  
  
  
                      Adi = ((Node) adiList.item(0)).getNodeValue();
                      online = ((Node) onlineList.item(0)).getNodeValue();
                      Logo = ((Node) logoList.item(0)).getNodeValue();
                      msUrlx = ((Node) msUrlList.item(0)).getNodeValue();
                      playStatus = Integer.parseInt(((Node) playStatusList.item(0)).getNodeValue());
  
  
                      defaultList.add(new MainList(Adi,online, Logo, msUrlx,playStatus));
  
  
                  }
  
              } catch (Exception e) {
                  System.out.println("XML READING ERROR-MAIN = " + e);
              }
          return defaultList;
          }
  
  
      public void setCheck(int a, String playStatus) {
         int mainListViewResult =  Main2.this.MainListOlustur().get(a).getPlayStatus();
          Log.e("DURUM",a+") "+playStatus+"-"+mainListViewResult);
          if (mainListViewResult != Integer.parseInt(playStatus))
          {
              Log.w("DURUM",a+"-"+playStatus+"-"+mainListViewResult);
              MainListOlustur().set(a,MainListOlustur().get(a)).setPlayStatus(View.VISIBLE);
  
              CustomAdapter myAdapter2 = new CustomAdapter(this,MainListOlustur());
              defaultList.setAdapter(myAdapter2);
  myAdapter2.notifyDataSetChanged();
          }
  
          }
      }
  </code></pre>
  
  <p>UpdateXML.class</p>
  
  <pre><code>public class UpdateXML extends AsyncTask{
  
  private Handler mHandler = new Handler();
  
  
  private void startTime() {
      mHandler.removeCallbacks(mUpdateTimeTask);
      mHandler.postDelayed(mUpdateTimeTask, 15000);
  }
  private Runnable mUpdateTimeTask = new Runnable() {
      public void run() {
          mHandler.postDelayed(this, 15000);
  
          try {
  
              URL url2 = new URL("http://.../data.xml");
              DocumentBuilderFactory dbf2 = DocumentBuilderFactory.newInstance();
              DocumentBuilder db2 = dbf2.newDocumentBuilder();
              Document doc2 = db2.parse(new InputSource(url2.openStream()));
              doc2.getDocumentElement().normalize();
  
              NodeList nodeList2 = doc2.getElementsByTagName("kanal");
  
              Main2 runC = new Main2();
  
              for (int iXml = 0; iXml &lt; nodeList2.getLength(); iXml++) {
  
                  Node node2 = nodeList2.item(iXml);
  
                  Element fstElmnt2 = (Element) node2;
                  NodeList playStatusList2 = fstElmnt2.getElementsByTagName("playStatus");
                  Element playStatusElement2 = (Element) playStatusList2.item(0);
                  playStatusList2 = playStatusElement2.getChildNodes();
                  String playStatus2 = playStatusList2.item(0).getNodeValue();
  
  
                  runC.setCheck(iXml,playStatus2);
  
                // Log.e("DURUM","XML L = "+iXml+") " + playStatus2);
  
              }
  
          } catch (Exception e) {
              Log.e("DURUM","XML READING ERROR-UpdateXML = " + e);
          }
  
      }
  };
  }
  </code></pre>
  
  <p>CustomAdapter.class</p>
  
  <pre><code>public class CustomAdapter extends BaseAdapter {
      private LayoutInflater mInflater;
      private java.util.List mListListesi;
      private String listeler[];
      TextView textViewOnline;
      MainList mainList;
      String streamURL;
      int playStatus;
  
  
      public CustomAdapter(Activity activity, java.util.List kisiler) {
          mInflater = (LayoutInflater) activity.getSystemService(
                  Context.LAYOUT_INFLATER_SERVICE);
          mListListesi = kisiler;
      }
  
      public void updateList(java.util.List kisiler) {
      kisiler.clear();
      kisiler.addAll(kisiler);
      this.notifyDataSetChanged();
  }
      @Override
      public int getCount() {
          return mListListesi.size();
      }
  
  
      @Override
      public MainList getItem(int position) {
          return (MainList) mListListesi.get(position);
      }
  
      @Override
      public long getItemId(int position) {
          return position;
      }
  
  
  @Override
  
      public View getView(int position, View convertView, ViewGroup parent) {
          View satirView;
  
          satirView = mInflater.inflate(R.layout.satir_layout, null);
          TextView textViewKanalAdi = (TextView) satirView.findViewById(R.id.kanalAdi);
          textViewOnline = (TextView) satirView.findViewById(R.id.online);
          final ImageButton playBtn = (ImageButton) satirView.findViewById(R.id.playBtn);
          ProgressBar loader = (ProgressBar) satirView.findViewById(R.id.playStatus);
          final TextView fullText = (TextView) satirView.findViewById(R.id.fullText);
          final Long itemID;
  
          itemID=getItemId(position);
  
  
          mainList = (MainList) mListListesi.get(position);
  
          listeler = new String[]{mainList.getkanalAdi()};
          streamURL = mainList.getMsurl();
  
          playStatus= mainList.getPlayStatus();
  
          textViewKanalAdi.setText(mainList.getkanalAdi());
          textViewOnline.setText(mainList.getOnline());
  
          return satirView;
  
      }
  }
  </code></pre>
  
  <p>AndroidManifest</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
  &lt;manifest xmlns:android="http://schemas.android.com/apk/res/android"
      package="com.test.net.tv"&gt;
      &lt;uses-permission android:name="android.permission.INTERNET"/&gt;
      &lt;uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /&gt;
      &lt;uses-permission android:name="android.permission.WAKE_LOCK" /&gt;
      &lt;uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /&gt;
  
  
      &lt;application
          android:allowBackup="true"
          android:icon="@mipmap/ic_launcher"
          android:label="@string/app_name"
          android:supportsRtl="true"
          android:theme="@style/AppTheme"&gt;
  
          &lt;activity android:name=".MainActivity"&gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.Main2"
                      /&gt;
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
  
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".TV"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.MAIN"
                      android:theme="@android:style/Theme.NoTitleBar.Fullscreen"/&gt;
  
                  &lt;category android:name="android.intent.category.LAUNCHER" /&gt;
  
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
          &lt;activity
              android:name=".TvFull"
              android:label="@string/app_name" &gt;
              &lt;intent-filter&gt;
                  &lt;action android:name="android.intent.action.TvFull" /&gt;
  
                  &lt;category android:name="android.intent.category.DEFAULT" /&gt;
              &lt;/intent-filter&gt;
          &lt;/activity&gt;
      &lt;/application&gt;
  
  &lt;/manifest&gt;
  </code></pre>
  
  <p>TvFull.class</p>
  
  <pre><code>public class TvFull extends Activity{
  
  private static final String TAG = null;
  VideoView videoView, videoView22;
  ProgressDialog progDailog;
  String myuri,msurlPlayer,str;
  
  protected void onCreate(Bundle savedInstanceState) {
  
      super.onCreate(savedInstanceState);
      setRequestedOrientation (ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
          setContentView(R.layout.tvfull);
  
      Bundle degiskenler=getIntent().getExtras();
      if(degiskenler != null){
  
          msurlPlayer = degiskenler.getString("msurl");
  
          Log.e("---msurl---",msurlPlayer);
      }
      else{
          Log.e("---msurl---","NULLLLLLL !!");
  
      }
          videoView = (VideoView)findViewById(R.id.videoView2); 
  
  
          myuri=msurlPlayer;
  
          videoView.setVideoPath(myuri);
          videoView.requestFocus();
  
          ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
          NetworkInfo netInfo = cm.getActiveNetworkInfo();
          if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) {
  
                  videoView.start();
  
  
                     progDailog = ProgressDialog.show(this, "", "Loading...", true);
  
                      videoView.setOnPreparedListener(new OnPreparedListener() {
  
                          public void onPrepared(MediaPlayer mp) {
                              progDailog.dismiss();
                          }
                      });
  
  
              }
  
          else {
  
              new AlertDialog.Builder(this)
              .setTitle("Connection error !")
              .setMessage("The device must have an internet connection to use the application!")
              .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) { 
                      finish();
                  }
               })
              .setIcon(android.R.drawable.ic_dialog_alert)
               .show();
          };
  
  
  
          ;       
  }
  
  
  
  
  @Override
  public boolean onTouchEvent(MotionEvent ev) {
     final TextView txt1 = (TextView) findViewById(R.id.textViewBaglantiKontrol);
      videoView22 = (VideoView)findViewById(R.id.videoView2); 
      if(ev.getAction() == MotionEvent.ACTION_DOWN){
          Log.d(TAG, "ACTION_DOWN");
  
          if (videoView22.isPlaying()){
              videoView22.pause();
              txt1.setText("Stopped");
  
  
              final Handler h = new Handler();
              h.postDelayed(new Runnable()
              {
                  private long time = 0;
  
                  @Override
                  public void run()
                  {
  
                      time += 1000;
  
                      if(time==3000){
  
                          Log.d("Timer", "OK!" + time);
                          txt1.setText("");
                      }
                          else{
                               h.postDelayed(this, 1000);
  
                          }
                      ;
  
                  }
              }, 1000); 
  
  
          }
          else if(videoView22.isPlaying()==false) {
              ConnectivityManager cm = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);
              NetworkInfo netInfo = cm.getActiveNetworkInfo();
              if (netInfo != null &amp;&amp; netInfo.isConnectedOrConnecting()) {
  
                  videoView22.start();
                  txt1.setText("Playing");
  
  
                  final Handler h = new Handler();
                  h.postDelayed(new Runnable()
                  {
                      private long time = 0;
  
                      @Override
                      public void run()
                      {
  
                          time += 1000;
                          Log.d("Timer", "Player Notification:" + time);
                          if(time==3000){
  
                              Log.d("Timer", "OK !" + time);
                              txt1.setText("");
                          }
                              else{
                                   h.postDelayed(this, 1000);
  
                              }
                          ;
  
                      }
                  }, 1000); 
  
  
              }
  
          else {
  
  
              new AlertDialog.Builder(this)
              .setTitle("Connection error!")
              .setMessage("The device must have an internet connection to use the application!")
              .setPositiveButton(android.R.string.yes, new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int which) { 
                      finish();
                  }
               })
              .setIcon(android.R.drawable.ic_dialog_alert)
               .show();
  
  
          };
  
  
          }
          }
  
      return super.onTouchEvent(ev);
  }
  @Override
  public void onDestroy() {
          videoView.stopPlayback();
  
  
      super.onDestroy();
  
  }
  
  
  }
  </code></pre>