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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T12:16:32+00:00 2026-06-17T12:16:32+00:00

I think this is a basic question. Is there any option to stop an

  • 0

I think this is a basic question. Is there any option to stop an activity by using intent.

Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:5554"));
startActivity(intent);

This is my code. I would like to stop this activity (That means, i want to drop this call) if the user is busy or something. What can I do for that? I tried this:

if (condition) {
    Intent intent = new Intent(Intent.ACTION_CALL,Uri.parse("tel:5554"));
    startActivity(intent);
}else {
    this.finish();
}

But of no use. Does anybody have a suggestion?

  • 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-17T12:16:33+00:00Added an answer on June 17, 2026 at 12:16 pm

    I had this problem a few days ago, and I’m happy to tell you I’ve found a way around this.

    First of all, to the activity you want to stop add this in the AndroidManifest.xml:

    android:launchMode="singleTop"
    

    I’m going to use a CheckBox example. When it’s checked the activity is started and when unchecked will kill the activity.

    Example Activity A is calling Activity B and then killing it using an intent.

    Code to be put in A:

    checkbox.setOnClickListener(new View.OnClickListener() {
    
            @Override
            public void onClick(View arg0) {
                Intent intent = new Intent(A.this, B.class);
                intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
                intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
                if (enable.isChecked()) {
                    intent.putExtra("keep", true);
                    startActivity(intent);
                }
                else
                {
                    intent.putExtra("keep", false);
                    startActivity(intent);
                }
            }
        });
    

    Code to be put into B:

    boolean keep;
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.B);
        intent = this.getIntent();
        boolean keep = intent.getExtras().getBoolean("keep");
        if(keep==true)
        {
            //execute your code here
    
        }
     }
        @Override
    protected void onNewIntent(Intent intent)
    {
        super.onNewIntent(intent);
        keep = intent.getExtras().getBoolean("keep");
        if(keep==false)
        {
            B.this.finish();
        }
    }
    

    Explanation : What this basically does is, when the checkbox is checked it calls the activity and passes a boolean value, if it’s true the activity is kept alive and is brought to the foreground. Now, if you don’t pass the flag singleTop then many instances of this activity will be created. singleTop makes sure only the same instance is called. Now, when the checkbox is unchecked a new value for keep is passed which is verified in B. If unchecked, the Activity A will be passing false, and hence B terminates itself from within the onNewIntent() function.

    P.S – You can close Activity B from another Activity too. Just use
    If the other activity is C:

    Intent intent = new Intent(C.this, B.class);
    intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP);
    intent.addFlags(Intent.FLAG_ACTIVITY_SINGLE_TOP);
    intent.putExtra("keep", false);
    startActivity(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am relatively new to XSL and I think this is a basic question.
(I think this is a pretty basic question on OOP, but unfortunately I wasn't
I think this is a pretty basic question, but after Googling around I can't
I am new to WCF so I think this is pretty basic. I have
New to rails and I have what I think is a basic question. In
I think I have a basic understanding of this, but am hoping that someone
I think this could be a very easy question for you. But I have
I think this is a simple and a silly question. I have included a
I think this is nearly impossible or very tricky. I'm using CriteriaBuilder, JPA 2.0,
I am relatively new to jQuery and pardon if this question is too simple,

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.