title: Android application restart on System.exit(0);
body: <p>I'm creating an app that has some threads and I want to close it.I tried:</p>
  
  <pre><code>System.exit(0);
  </code></pre>
  
  <p>But the application restart itself.</p>
  
  <p>Please help me,thanks.</p>
  
  <p>EDIT:</p>
  
  <p>OnDestroy code:</p>
  
  <pre><code>@Override
  public void onDestroy(){
      android.os.Process.killProcess(android.os.Process.myPid());
  }
  </code></pre>
  
  <p>OnOptionsItemClicked:</p>
  
  <pre><code>@Override
  public boolean onOptionsItemSelected(MenuItem item) {
      switch (item.getItemId()) {
      case R.id.item1:
          startActivity(new Intent(this, ConnActivity.class));
          finish();
          break;
      case R.id.item2:
          android.os.Process.killProcess(android.os.Process.myPid());
          System.exit(0);
          break;
      case R.id.item3:
          AlertDialog.Builder alert = new AlertDialog.Builder(this);
  
          alert.setTitle("Mensaje al servidor");
          alert.setMessage("Enviar mensaje al servidor");
  
          // Set an EditText view to get user input 
          final EditText input = new EditText(this);
          alert.setView(input);
  
          alert.setPositiveButton("Enviar", new DialogInterface.OnClickListener() {
          public void onClick(DialogInterface dialog, int whichButton) {
            String value = input.getText().toString();
            MessageRequest msqr = new MessageRequest();
            msqr.msg = new Packets.Message();
            msqr.msg.lidfrom = pi.getPhoneLoginIdentifier();
            msqr.msg.lidto = new LoginIdentifier("SERVER","SERVER","-1");
            msqr.msg.msg = value;
            setTime(msqr.msg);
            send(msqr);
            }
          });
  
          alert.setNegativeButton("Cancelar", new DialogInterface.OnClickListener() {
            public void onClick(DialogInterface dialog, int whichButton) {
               dialog.dismiss();
            }
          });
          try{
              alert.show();
          }catch(Exception e){
          }
  
          break;
      }
      return true;
  }
  </code></pre>