title: Black screen while AsyncTask is running
body: <p>I'm new to asking questions here so any advice about that will be appreciated...but to my problem:</p>
  
  <p>I'm trying to switch from one activity to another, where I'll show some data from the server. I'm pulling the data from server via AsyncTask but there is black screen showing between the activities, when the download is longer. I already tried to put the AsyncTask from onCreate() to onStart() but no change there.</p>
  
  <p>New activity:</p>
  
  <pre><code>public class SalesMenu extends Activity {
  
  @Override
  protected void onCreate(Bundle savedInstanceState) {
      requestWindowFeature(Window.FEATURE_INDETERMINATE_PROGRESS);
      setContentView(R.layout.sales_menu);        
      setProgressBarIndeterminateVisibility(true);
      super.onCreate(savedInstanceState);
  }
  
  @Override
  protected void onStart() {
      List&lt;HashMap&lt;String, Object&gt;&gt; result = null;
      AsyncTask&lt;Void, Boolean, List&lt;HashMap&lt;String, Object&gt;&gt;&gt; aTask = new AsyncSearchRead(
              "sale.order", 
              new Object[0], 
              new String[] {"name"}, 
              this).execute();
  
      try {
          result = aTask.get();
      } catch (InterruptedException e) {
          e.printStackTrace();
      } catch (ExecutionException e) {
          e.printStackTrace();
      }
      Log.d("test", (result!=null ? result.toString() : "nothing"));
      super.onStart();
  }
  
  }
  </code></pre>
  
  <p>My AsyncTask:</p>
  
  <pre><code>public class AsyncSearchRead extends AsyncTask&lt;Void, Boolean, List&lt;HashMap&lt;String, Object&gt;&gt;&gt; {
  String mModel; 
  boolean mCount; 
  Integer mOffset;
  Integer mLimit; 
  String mOrder; 
  boolean mReverseOrder; 
  Object[] mConditions;
  String[] mFields;
  Activity parentActivity;
  
  public AsyncSearchRead(String model, boolean count, Integer offset, Integer limit, 
                      String order, boolean reverseOrder, Object[] conditions, String[] fields,
                      Activity activity) {
      mModel = model;
      mCount = count;
      mOffset = offset;
      mLimit = limit;
      mOrder = order;
      mReverseOrder = reverseOrder;
      mConditions = conditions;
      mFields = fields;
      parentActivity = activity;
  }
  
  @Override
  protected List&lt;HashMap&lt;String, Object&gt;&gt; doInBackground(Void... params) {
      Long[] ids;
      List&lt;HashMap&lt;String, Object&gt;&gt; results;
              //Downloading the data
      ids = SetServer.connection.search(mModel, mCount, mOffset, mLimit, mOrder, mReverseOrder, mConditions);
      results = SetServer.connection.read(mModel, ids, mFields);
  
      return results;
  }
  
  @Override
  protected void onPostExecute(List&lt;HashMap&lt;String, Object&gt;&gt; result) {
      parentActivity.setProgressBarIndeterminateVisibility(false);
  }
  
  }
  </code></pre>
  
  <p>When I did not turn visibility off onPostExecute it kept spinning after showing the activity but it's only shown after the loading. </p>
  
  <p>How can I get it to show the activity and only after that start to load the data and show some progress bar/loader?</p>
  
  <p>Thanks for any help.</p>