title: I hope toast can disappear immediately when fragment finish
body: <p>I hope toast can disappear immediately when fragment finish.</p>
  
  <p>There is a ToastUtils Class.</p>
  
  <pre><code>import android.content.Context;
  import android.widget.Toast;
  
  public class ToastUtils{
      private static Toast mToast;
      public static void showToast(Context context, int msg, int duration) {
          if (mToast == null) {
              mToast = Toast.makeText(context, msg, duration);
          } else {
              mToast.setText(msg);
          }
          mToast.show();
      }
      public static void showToast(Context context, String msg, int duration) {
          if (mToast == null) {
              mToast = Toast.makeText(context, msg, duration);
          } else {
              mToast.setText(msg);
          }
          mToast.show();
      }
      public static void clearToast(){
          mToast.cancel();
      }
  }
  </code></pre>
  
  <p>Many people says that overriding <strong>onStop</strong> can solve this problem.</p>
  
  <p>So I override function <strong>onStop</strong> in the fragment</p>
  
  <pre><code>@Override
      public void onStop(){
          super.onStop();
          ToastUtils.clearToast();
      }
  </code></pre>
  
  <p>But it gives an exception</p>
  
  <pre><code>08-07 14:48:50.070  11178-11178/? W/System.err﹕ java.lang.NullPointerException
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at com.shijiebang.offlinemap.utils.ToastUtils.clearToast(ToastUtils.java:30)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at com.shijiebang.offlinemap.ui.Fragment.LoginFragment.onStop(LoginFragment.java:173)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.Fragment.performStop(Fragment.java:1888)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:948)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1071)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.FragmentManagerImpl.moveToState(FragmentManager.java:1053)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.FragmentManagerImpl.dispatchStop(FragmentManager.java:1880)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.Activity.performStop(Activity.java:5471)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:3713)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3772)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.ActivityThread.access$1700(ActivityThread.java:139)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1309)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.os.Handler.dispatchMessage(Handler.java:102)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.os.Looper.loop(Looper.java:136)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at android.app.ActivityThread.main(ActivityThread.java:5314)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at java.lang.reflect.Method.invokeNative(Native Method)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at java.lang.reflect.Method.invoke(Method.java:515)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:864)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:680)
  08-07 14:48:50.075  11178-11178/? W/System.err﹕ at dalvik.system.NativeStart.main(Native Method)
  </code></pre>
  
  <p>I Don't know the reason. Please help!</p>