title: WaitingInMainSignalCatcherLoop Thread reacting to signal 3 ANR
body: <p>I am getting application not responding when i try parse a json output and display my output in activity made up of fragments.
  As the ouput keeps on changing i add my fragments dynamically based on the type of widget I get from the respnse.'
  The fragments can be 10-15.As seen in one of the answer on stackoverflow i have kept my logic for parsing on a separate thread and then i add the fragment on ui thread.</p>
  
  <pre><code>    @Override
      protected void onPostExecute(String s) {
          progressBar.setVisibility(View.GONE);
          if (!s.equalsIgnoreCase("") &amp;&amp; !s.equalsIgnoreCase("null")) {
              fragment_container.setVisibility(View.VISIBLE);
              network_error.setVisibility(View.GONE);
              try {
                  JSONObject jsonObject = new JSONObject(s);
                  JSONArray widgetJsonArray = jsonObject.getJSONArray("widgets");
                  for (int i = 0; i &lt; widgetJsonArray.length(); i++) {
                      JSONObject widgetObject = widgetJsonArray.getJSONObject(i);
                      String widget_type = widgetObject.getString("widget_type");
                      if (widget_type.equalsIgnoreCase("auto_product_deals")) {
                          processAutoProductDeals(widgetObject);
                      } else if (widget_type.equalsIgnoreCase("manual_product")) {
                          processManualProduct(widgetObject);
                      } else if (widget_type.equalsIgnoreCase("manual_list")) {
                          processManualList(widgetObject);
                      }
                  }
              } catch (JSONException e) {
                  e.printStackTrace();
              }
          } else {
              network_error.setVisibility(View.VISIBLE);
          }
      }
  
      private void processManualList(final JSONObject widgetObject) {
          Thread thread = new Thread() {
              @Override
              public void run() {
                  try {
                      ArrayList&lt;ManualListPojo&gt; listManual = new ArrayList&lt;&gt;();
                      JSONObject dataObject = widgetObject.getJSONObject("data");
                      String title = dataObject.getString("title");
                      if (!title.equalsIgnoreCase("shop by brand") &amp;&amp; !title.equalsIgnoreCase("shop by discount")) {
                          JSONArray dealsArray = dataObject.getJSONArray("deals");
                          for (int i = 0; i &lt; dealsArray.length(); i++) {
                              ManualListPojo manualDealPojo = new ManualListPojo();
                              JSONObject manualObject = dealsArray.getJSONObject(i);
                              manualDealPojo.setTitle(manualObject.getString("title"));
                              manualDealPojo.setImage(manualObject.getString("image"));
                              manualDealPojo.setPrice_text(manualObject.getString("price_text"));
                              manualDealPojo.setValid_till(manualObject.getString("valid_till"));
                              manualDealPojo.setStore(manualObject.optString("store"));
                              JSONObject linkObject = manualObject.getJSONObject("link");
                              if (linkObject.has("category"))
                                  manualDealPojo.setCategory(linkObject.getString("category"));
                              if (linkObject.has("comparables"))
                                  manualDealPojo.setComparables(linkObject.getString("comparables"));
                              if (linkObject.has("url"))
                                  manualDealPojo.setUrl(linkObject.getString("url"));
                              if (linkObject.has("filters")) {
                                  JSONObject filtersObject = linkObject.getJSONObject("filters");
                                  if (filtersObject.has("properties")) {
                                      JSONArray properties = filtersObject.getJSONArray("properties");
                                      ArrayList&lt;String&gt; propertiesArray = new ArrayList&lt;&gt;();
                                      for (int j = 0; j &lt; properties.length(); j++) {
                                          propertiesArray.add(properties.getString(j));
                                      }
                                      manualDealPojo.setProperty(propertiesArray);
                                  }
                                  if (filtersObject.has("price")) {
                                      JSONObject priceObject = filtersObject.optJSONObject("price");
                                      manualDealPojo.setMin(priceObject.optString("min"));
                                      manualDealPojo.setMax(priceObject.optString("max"));
                                  }
                                  manualDealPojo.setSort(filtersObject.optString("sort"));
                              }
                              listManual.add(manualDealPojo);
                          }
                      }
                      if (listManual.size() &gt; 0) {
                          final Activity activity = (Activity) IndexActivity.this;
                          if (activity != null &amp;&amp; !activity.isFinishing()) {
                              final FragmentManager fragmentManager = getFragmentManager();
                              final ManualListFragment hello = new ManualListFragment(listManual, title);
                              runOnUiThread(new Runnable() {
                                  @Override
                                  public void run() {
                                      FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                                      fragmentTransaction.add(R.id.fragment_container, hello, "Manual_List");
                                      fragmentTransaction.commitAllowingStateLoss();
                                  }
                              });
  
                          }
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
          };
          thread.start();
  
      }
  
      private void processManualProduct(final JSONObject widgetObject) {
          Thread thread = new Thread() {
              @Override
              public void run() {
                  try {
                      ArrayList&lt;ItemPojo&gt; listItem = new ArrayList&lt;&gt;();
                      JSONObject dataObject = widgetObject.getJSONObject("data");
                      String title = dataObject.getString("title");
                      JSONArray jsonItemArray = dataObject.getJSONArray("items");
                      for (int i = 0; i &lt; jsonItemArray.length(); i++) {
                          JSONObject itemObject = jsonItemArray.getJSONObject(i);
                          ItemPojo itemPojoObject = new ItemPojo();
                          itemPojoObject.setImage(itemObject.getString("image"));
                          itemPojoObject.setId(itemObject.getString("id"));
                          itemPojoObject.setFinal_price(itemObject.getString("final_price"));
                          if (itemObject.has("mrp")) {
                              itemPojoObject.setMrp(itemObject.getString("mrp"));
                          }
                          itemPojoObject.setPrice(itemObject.getString("price"));
                          itemPojoObject.setTitle(itemObject.getString("title"));
                          itemPojoObject.setRatings(itemObject.getString("ratings"));
                          itemPojoObject.setDiscount(itemObject.getString("discount"));
                          itemPojoObject.setAvg_rating(itemObject.getString("avg_rating"));
                          listItem.add(itemPojoObject);
                      }
                      final Activity activity = (Activity) IndexActivity.this;
                      if (activity != null &amp;&amp; !activity.isFinishing()) {
                          final FragmentManager fragmentManager = getFragmentManager();
                          final ManualProductFragment hello = new ManualProductFragment(listItem, title);
                          runOnUiThread(new Runnable() {
                              @Override
                              public void run() {
                                  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                                  fragmentTransaction.add(R.id.fragment_container, hello, "Manual_Product");
                                  fragmentTransaction.commitAllowingStateLoss();
                              }
                          });
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
          };
          thread.start();
  
      }
  
  
      private void processAutoProductDeals(final JSONObject widgetObject) {
          final Thread thread = new Thread() {
              @Override
              public void run() {
                  try {
                      ArrayList&lt;DealPojo&gt; listDeal = new ArrayList&lt;&gt;();
                      JSONObject dataObject = widgetObject.getJSONObject("data");
                      String title = dataObject.getString("title");
                      JSONArray dealsArray = dataObject.getJSONArray("deals");
                      for (int i = 0; i &lt; dealsArray.length(); i++) {
                          JSONObject dealObject = dealsArray.getJSONObject(i);
                          DealPojo dealPojoObject = new DealPojo();
                          dealPojoObject.setStore(dealObject.getString("store"));
                          String url = dealObject.getString("url");
                          if (url.contains("sendtostore.php")) {
                              url.replace("sendtostore", "justswipe");
                          }
                          dealPojoObject.setUrl(url);
                          dealPojoObject.setId(dealObject.getString("id"));
                          dealPojoObject.setPrice(dealObject.getString("price"));
                          dealPojoObject.setMrp(dealObject.getString("mrp"));
                          dealPojoObject.setPrice_text(dealObject.getString("price_text"));
                          dealPojoObject.setTitle(dealObject.getString("title"));
                          dealPojoObject.setImage(dealObject.getString("image"));
                          listDeal.add(dealPojoObject);
                      }
                      final Activity activity = (Activity) IndexActivity.this;
                      if (activity != null &amp;&amp; !activity.isFinishing()) {
                          final FragmentManager fragmentManager = getFragmentManager();
                          final AutoProductDeal hello = new AutoProductDeal(listDeal, title);
                          runOnUiThread(new Runnable() {
                              @Override
                              public void run() {
                                  FragmentTransaction fragmentTransaction = fragmentManager.beginTransaction();
                                  fragmentTransaction.add(R.id.fragment_container, hello, "Auto_Product");
                                  fragmentTransaction.commitAllowingStateLoss();
                              }
                          });
  
                      }
                  } catch (JSONException e) {
                      e.printStackTrace();
                  }
              }
          };
          thread.start();
  
      }
  </code></pre>