title: Android java.lang.IllegalStateException: Call while result is not pending
body: <p>I have a logout funcion. So when user logs out I want to abort BroadcastReceiver. But getting error as in Title. What am I doing wrong?</p>
  
  <pre><code>public static void logout(Context context, String empid)
  {
      try
      {
          Log.d("Testing", "TRY 2  LOGOUT me " + empid );
          try
          {
              Log.d("Testing", "TRY handle logout");
              db = new DbAdapter_User(context);
              db.open();
              db.handleLogout();
              db.close();
          }
          catch(Exception e)
          {
              Log.d("Testing", "CATCH handlelogout " + e.toString());
          }
          Log.d("Testing", "When logout class is " +  context.getClass());
          if (!context.getClass().equals(LogIn.class))
          {
               Log.d("Testing", "In IF When logout class is " +  context.getClass());
              context.startActivity(new Intent(context, LogIn.class).addFlags(Intent.FLAG_ACTIVITY_NEW_TASK));
          }
          Log.d("Testing", "logout: setting Global variables ");
          ((GlobalMobileVianet)context.getApplicationContext()).setUserId("000000");
          ((GlobalMobileVianet)context.getApplicationContext()).setPassword("");
          Log.d("Testing", "logout: DONE setting Global variables ");
          try
          {
              Log.d("Testing", "TRY session manager aborted");
              SessionManager sessionManager = new SessionManager();
              sessionManager.abortBroadcast();
           }
          catch(Exception e)
          {
              Log.d("Testing", "CATCH session manager aborted " + e.toString());
          }
           LogoutNotification(context);
  
      }
      catch (Exception e)
      {
          Log.d("Testing", "CATCH 2  LOGOUT me " + e.toString() );
      }
  }
  </code></pre>