title: Retrieving saved value in onResume in android api 26
body: <p>I am having an issue with saving and retrieving values in singleton class only in android oreo.I have an activity which has 4 fragments.1st fragment shows productlist.Whenever user selects that product,I am saving that product in singleton class variable.Now when I try to retrieve this value in second fragment.It shows null pointer exception.
  I am storing value in onStop() and retrieving value in onResume().
  Below is the onStop Method of fragmentProduct where I am storing order in orderList</p>
  
  <p><strong>FragmentProduct</strong></p>
  
  <pre><code> public void onStop()
      {
          super.onStop();
          Log.d("stop","called");
          globalProvider.shangpingListDefault.clear();
          if(MiTems!=null) {
              for(int i=0;i&lt;MiTems.size();i++){
                  for(int a=0;a&lt;MiTems.get(i).size();a++){
                      globalProvider.shangpingListDefault.add(MiTems.get(i).get(a));
                  }
              }
  
          }
  
          List&lt;OrderSubmit&gt; orderList=new ArrayList&lt;OrderSubmit&gt;();
          this.shangPingList=globalProvider.shangpingList;
          List&lt;Contract&gt; contractList=globalProvider.contractListToCart;
          for (int i = 0; i &lt; globalProvider.contractListToCart.size(); i++) {
              //globalProvider.orders.add(new OrderSubmit());
              OrderSubmit order = new OrderSubmit();
              order.products = new ArrayList&lt;Product&gt;();
              //Contract contract=globalProvider.contractListToCart.get(i);
              for (int a = 0; a &lt; globalProvider.shangpingList.size(); a++) {
                  Product product = globalProvider.shangpingList.get(a);
                  if (globalProvider.contractListToCart.get(i)._supplier.equals(product.get_supplier())) {
                      order.products.add(product);
                  }
              }
              orderList.add(order);
              Log.d("orderlist","orderadded");
          }
  </code></pre>
  
  <p>Below is the OnResumeMethod of FragmentCart where I am retrieving order in onResume</p>
  
  <p><strong>FragmentCart</strong></p>
  
  <pre><code>public void onResume()
      {
          super.onResume();
  
          orders=globalProvider.orders;
          Log.d("checksizeorder",globalProvider.orders.size()+"");
  
          setSelect();
  
      }
  </code></pre>
  
  <p>In MainActivity,whenever tab is selected I am replacing these fragment:
  <strong>MainActivity</strong></p>
  
  <pre><code>public void setSelect(int i){
          FragmentManager fm=getFragmentManager();
          FragmentTransaction transaction=fm.beginTransaction();
          //hide(transaction);
          switch(i){
              case 0:
                  if(globalProvider.singal==0){
                      return;
                  }
                  globalProvider.singal=0;
                  FragmentContract fragment_contract = new FragmentContract();
                  transaction.replace(R.id.main, fragment_contract);
                  shangping_Img.setImageResource(R.drawable.shangping_pressed);
                  cart_Img.setImageResource(R.drawable.cart);
                  dingdan_Img.setImageResource(R.drawable.dingdan);
                  wode_Img.setImageResource(R.drawable.my_info);
                  one.setTextColor(0xffee2400);
                  two.setTextColor(0xff666666);
                  three.setTextColor(0xff666666);
                  four.setTextColor(0xff666666);
                  break;
              case 1:
                  if(globalProvider.singal==1){
                      return;
                  }
                  globalProvider.singal=1;
                  FragmentCart cart_fragment=new FragmentCart();
                  transaction.replace(R.id.main, cart_fragment);
                  shangping_Img.setImageResource(R.drawable.shangping);
                  cart_Img.setImageResource(R.drawable.cart_pressed);
                  dingdan_Img.setImageResource(R.drawable.dingdan);
                  wode_Img.setImageResource(R.drawable.my_info);
                  one.setTextColor(0xff666666);
                  two.setTextColor(0xffee2400);
                  three.setTextColor(0xff666666);
                  four.setTextColor(0xff666666);
                  break;
  </code></pre>