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 6380995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T02:20:21+00:00 2026-05-25T02:20:21+00:00

I need to be able to tell when a spawned activity (via an intent)

  • 0

I need to be able to tell when a spawned activity (via an intent) has completed, how would I do so?

This is what I have:

    alertDialog.setButton2("Text", new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            String uri = "smsto:" + "";
            Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
            intent.putExtra("sms_body", PASSWORD_GENERATOR
                    .generatePasswordForSeed(seedText, hourToUse));
            intent.putExtra("compose_mode", true);

            // -- open the text message activity
            startActivity(intent);

            // -- I need to reset the calling activity now, but AFTER the text message activity has completed. Right now the SMS closes right away as I have no wait in...
            finish();
            startActivity(getIntent());
        }
    });

EDIT #1

Per the suggestions below, I’ve made some modifications. Now, however, the launched SMS activity just “sits there” once the text is sent. I can’t figure out how to get it to return to the calling activity. This is what I have:

alertDialog.setButton2("Text", new DialogInterface.OnClickListener() {
            @Override
            public void onClick(DialogInterface dialog, int which) {
                String uri = "smsto:" + "";
                Intent intent = new Intent(Intent.ACTION_SENDTO, Uri.parse(uri));
                intent.putExtra("sms_body", PASSWORD_GENERATOR
                        .generatePasswordForSeed(seedText, hourToUse));
                intent.putExtra("compose_mode", true);

                startActivityForResult(intent, Activity.RESULT_OK);

                registerReceiver(new BroadcastReceiver() {
                    @Override
                    public void onReceive(Context context, Intent intent) {
                        finish();
                        startActivity(getIntent());
                    }

                }, new IntentFilter("SMS_SENT"));

                ContentResolver contentResolver = getContentResolver();
                Handler handler = new Handler();

                contentResolver.registerContentObserver(Uri
                        .parse("content://sms"), true, new ContentObserver(
                        handler) {

                    @Override
                    public boolean deliverSelfNotifications() {
                        setResult(Activity.RESULT_OK);
                        finish();

                        return super.deliverSelfNotifications();
                    }

                    @Override
                    public void onChange(boolean selfChange) {
                        super.onChange(selfChange);

                        setResult(Activity.RESULT_OK);
                        finish();
                    }
                });
            }
        });

        alertDialog.show();
    }

    @Override
    protected void onActivityResult(int requestCode, int resultCode, Intent data) {
        finish();
        startActivity(getIntent());
    }
  • 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-05-25T02:20:21+00:00Added an answer on May 25, 2026 at 2:20 am

    Followup Answer for second question:
    Out of curiosity, have you considered sending the text without creating an activity? The reason I ask is because it seems, from what I can tell, no user experience is happening within your SMS activity. If you don’t have views and user interactions then maybe just defining a thread or creating a helper class would do the job.

    Original Answer for first question:
    Try using startActivityForResult(Intent, int). Your current activity can get notified when the text message activity finishes.

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

Sidebar

Related Questions

I need to be able to tell if a link (URL) points to an
I need to be able to load the entire contents of a text file
I need to be able to tell the user if their password is strong
I need to be able to tell the difference between a string that can
I need to be able to tell from within a VB.NET class (not a
From an NT shell script, I need to be able to tell if the
I have a few ideas about this but here is what I need to
I need to be able to tell if a page is being viewed in
I need to be able to tell if an image exists in a directory
I need to be able to Tell if the file is a proper wav

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.