title: Where to setAdapter in AsyncTask?
body: <p>I'm trying to improve the performance of my mobile App. I'm attempting to use AsyncTask. I've looked at quite a lot of documentation on AsyncTask, also looked at numerous questions on here, but can't seem to get my code to run correctly.</p>
  
  <p>I've seen examples where the Adapter is set in the onPostExecute method, but that does not work for me..   </p>
  
  <pre><code> @Override
      protected void onCreate(@Nullable Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          setContentView(R.layout.activity_travel_updates);
  
  
  
          Twitter.initialize(this);
  
          new getTweets().execute();
      }
  
  
  private class getTweets extends AsyncTask&lt;Void, Void, Void&gt;{
  
  
      @Override
      protected void onPreExecute() {
          super.onPreExecute();
  
          final RecyclerView recyclerView = (RecyclerView) findViewById(R.id.recycler_view);
          recyclerView.setLayoutManager(new LinearLayoutManager(travel_updates.this));
      }
  
      @Override
      protected Void doInBackground(Void... params) {
          final UserTimeline searchTimeline = new UserTimeline.Builder().screenName("TflTravelAlerts")
                  .maxItemsPerRequest(5)
                  .build();
  
          final TweetTimelineRecyclerViewAdapter tweetAdapter =
                  new TweetTimelineRecyclerViewAdapter.Builder(travel_updates.this)
                          .setTimeline(searchTimeline)
                          .setViewStyle(R.style.tw__TweetLightWithActionsStyle)
                          .build();
          return null;
      }
  
      @Override
      protected void onPostExecute(Void Void) {
  
  recyclerView.setAdapter(tweetAdapter);
  
      }
    }
  }
  </code></pre>
  
  <p>Thanks</p>