title: Executing activity without showing the layout on screen
body: <p>I've searched not only stackoverflow, but another sites too, but I couldn't find an answer to my problem. I'm starting now to learn Android, and I have a doubt about activities.</p>
  
  <p>I have a MainActivity which creates a notification with two buttons. One is useless by now and the other (the Send button) will open an Alert with an EditText and a button to send the text to another app.</p>
  
  <p>This is the code:</p>
  
  <pre><code>Intent mainActivityIntent = new Intent(MainActivity.this, NotificationActivity.class);
              Intent shareActivityIntent = new Intent(MainActivity.this, ShareActivity.class);
              PendingIntent mainActivityPIntent = PendingIntent.getActivity(MainActivity.this, 0, mainActivityIntent, 0);
              PendingIntent shareActivityPIntent = PendingIntent.getActivity(MainActivity.this, 0, shareActivityIntent, 0);
  
              Notification n = new Notification.InboxStyle 
                      (new Notification.Builder(MainActivity.this)
                      .setContentTitle(getString(R.string.text_notification))
                      .setContentText(getString(R.string.text_notification))
                      .setSmallIcon(R.drawable.ic_launcher)
                      .setContentIntent(mainActivityPIntent)
                      .addAction(R.drawable.logo, "Botão", mainActivityPIntent)
                      .addAction(R.drawable.ic_launcher, "Share", shareActivityPIntent)
                              )
                      .build();
  
              n.flags |= Notification.FLAG_ONGOING_EVENT;
  
              NotificationManager nm = (NotificationManager) getSystemService(NOTIFICATION_SERVICE);
              nm.notify(0, n);
  </code></pre>
  
  <p>As you can see, the Send button will open another Activity, which has the code below:</p>
  
  <pre><code>AlertDialog.Builder alert = new AlertDialog.Builder(this);
  
      alert.setTitle("Mensagem");
      alert.setMessage("Digite a mensagem");
  
  
      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();
        Intent i = new Intent(Intent.ACTION_SEND);
          i.setType("text/plain");
          i.putExtra(Intent.EXTRA_TEXT, value);
          startActivity(Intent.createChooser(i, "Enviar"));
          finishActivity(0);
        }
      });
  
      alert.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
        public void onClick(DialogInterface dialog, int whichButton) {
          return;
        }
      });
  
      alert.show();
  </code></pre>
  
  <p>This activity is responsible for opening the alert where the user will input the text and send to another application. </p>
  
  <p>The situation is that when I call the activity it not only shows the alert but also open a new "screen". Example: the notification is persistent, so it will be always showing on the notification drawer. If I'm on another app and I click the button on my notification, I want to open only the alert, but now it's opening the alert AND the screen with the layout for my activity.</p>
  
  <p>Is there a way to show only the alert, without showing the activity? Or do I have to use another method to do this?</p>
  
  <p>Thank you very much.</p>