title: remove toast and also destroy or force stop thread
body: <p>hi i am working on custom toast , and i am able to do that, but after when i move to next activity the thread is running or active of back activity , so what should i do for removing that thread or stop this thread.</p>
  
  <p>my code is given below :</p>
  
  <pre><code>public void customToast(int x, int y, String str) {
      if (Util.tipson == true) {
          toast = new Toast(getApplicationContext());
          toast.setDuration(Toast.LENGTH_SHORT);
          toast.setGravity(Gravity.TOP, x, y);
          LayoutInflater li = (LayoutInflater) getSystemService(Context.LAYOUT_INFLATER_SERVICE);
          toastView = li.inflate(R.layout.toastlayout, null);
          toast.setView(toastView);
          TextView text = (TextView) toastView.findViewById(R.id.text);
          text.setText(str);
          // toast.show();
  
          fireLongToast();
      }
  
  }
  
  private void fireLongToast() {
  
      t = new Thread() {
          public void run() {
              int count = 0;
              try {
                  while (true &amp;&amp; count &lt; 40) {
                      try {
                          toast.show();
                          sleep(100);
                          count++;
                      } catch (Exception e) {
                          // TODO: handle exception
                      }
                      // do some logic that breaks out of the while loop
                  }
  
                  toast = null;
                  toastView = null;
              } catch (Exception e) {
                  Log.e("LongToast", "", e);
              }
          }
      };
      t.start();
  }
  </code></pre>