title: android : Unable to stop activity
body: <p>I am new to android. I have a loginActivity which validates a user number and then starts a "searchactivity".</p>
  
  <p>At runtime, I see the search activity coming up (after user is validated) but then android is having problems stopping the loginActivity.</p>
  
  <p>I am getting a "java.lang.runtimeexception: Unable to stop activity {com.insruance/com.insurance.LoginActivity}: android.app.SuperNotCalledException : Activity
  at android.app.ActivityThread.performStopActivityInner(ActivityThread.java:3413)"</p>
  
  <p>I would really appreciate if someone could point to what I am doing wrong.</p>
  
  <p>Code :</p>
  
  <pre><code>public class LoginActivity extends Activity{
  
   DatabaseWrapper myDbHelper;
   private String agentNumber;
   private OnClickListener btnClickListner = new OnClickListener() 
   {  
    @Override
    public void onClick(View v) 
    {
     // TODO Auto-generated method stub   
     // = new DataBaseHelper();   
     try {
  
      Log.d("LoginActivity-&gt;onClick", "Before findByID");
      EditText editText = (EditText)findViewById(R.id.txtUserNumber);
      Log.d("LoginActivity-&gt;onClick", "After findByID");
      agentNumber = editText.getText().toString();
      String msg = "";
      AgentDbHelper agentHelper = new AgentDbHelper(myDbHelper.getDatabaseHandle());
      Log.d("LoginActivity-&gt;onClick", "Before agentIDExists");    
      if (agentHelper.agentIDExists(agentNumber))
       msg = "Login success";
      else
       msg = "Login failed";
      Log.d("LoginActivity-&gt;onClick", "After agentByID");
      myDbHelper.closeDatabase();
      myDbHelper = null;
      Toast.makeText(getBaseContext(), 
        "User " + agentNumber + " found!", 
        Toast.LENGTH_LONG).show();
      callSearchActivity();
     } 
     catch(SQLException sqlEx)
     {
      Log.d("login - onclick", sqlEx.toString());
     }
     catch (Exception e) {
      // TODO: handle exception
      Log.d("login - onclick", e.toString());
     } 
    }
   }; 
  
   private void callSearchActivity()
   {
    Intent intent = new Intent(getBaseContext(), SearchActivity.class);
    Bundle bun = new Bundle();
    bun.putString("agentNumber", agentNumber);
    intent.putExtras(bun);
    startActivity(intent);  
   }
  
   @Override
   public void onStop() {  
    try {
     Log.d("In LoginActivity-&gt;onStop", "about to close myDbHelper");
     if (myDbHelper != null)
     {
      myDbHelper.closeDatabase();
      Log.d("In LoginActivity-&gt;onStop", "after myDbHelper is closed");
     }
    } catch (Exception e) {
     // TODO Auto-generated catch block
     Log.d("In LoginActivity-&gt;onStop exeption", e.toString());
     //e.printStackTrace();
    }
   }
   @Override
      public void onCreate(Bundle savedInstanceState) {
          super.onCreate(savedInstanceState);
          try {        
           setContentView(R.layout.login);
           Button loginButton = (Button)this.findViewById(R.id.btnLogin);
           loginButton.setOnClickListener(btnClickListner);
           myDbHelper = new DatabaseWrapper(this);
           myDbHelper.openDatabase();
          }
          catch(Exception e) {
        Log.e("ERROR", "ERROR IN CODE:"+e.toString());
       }
  </code></pre>
  
  <p>} 
  }</p>