Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8996137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:42:51+00:00 2026-06-15T23:42:51+00:00

I’ve searched not only stackoverflow, but another sites too, but I couldn’t find an

  • 0

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.

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.

This is the 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);

As you can see, the Send button will open another Activity, which has the code below:

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();

This activity is responsible for opening the alert where the user will input the text and send to another application.

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.

Is there a way to show only the alert, without showing the activity? Or do I have to use another method to do this?

Thank you very much.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T23:42:51+00:00Added an answer on June 15, 2026 at 11:42 pm

    If there’s no absolute need for an alert dialog, you can make the alert its own activity and just not use the alert builder. Put buttons and textviews or whatever you need as you would. Then in the manifest use

    <activity android:theme="@android:style/Theme.Dialog">

    Here is more about themes. Hope this helps

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I am using the SimpleRSS gem to parse a WordPress RSS feed. The only
I have a French site that I want to parse, but am running into
I want use html5's new tag to play a wav file (currently only supported
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
This could be a duplicate question, but I have no idea what search terms

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.