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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T02:59:43+00:00 2026-06-17T02:59:43+00:00

I think I need to put some code within my onStop method. It pertains

  • 0

I think I need to put some code within my onStop method. It pertains to a service that should be running only when the activity is finished()

but when the user follows some linkify‘d text to the web browser, or when the user presses the homescreen, both call onStop() but these do not end the activity, I don’t want to end the activity when a user follows a link, so I can’t put finish() within onStop() unless I can detect and differentiate when this happens within onStop()

is there a way I can override Linkify() so that I can add a flag within it, or maybe make it run startActivityforResult() so that I can information back in a result?

similarly, is there a way I can set the activity to finish() when the user presses the home button?

Thanks

  • 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-17T02:59:44+00:00Added an answer on June 17, 2026 at 2:59 am

    Is it possible for you to check isFinishing() in your onStop() to decide whether you need to run the service-related code or not?

    @Override
    protected void onStop() {
        super.onStop();
    
        if (isFinishing()) {
            // Your service-related code here that should only run if finish() 
            // was called.
        }
    }
    

    UPDATE: (after understanding the problem better)

    Very similar to my suggested approach on another question, you can probably override startActivity() to intercept when the link is launching and set your flag if that’s the case.

    @Override
    public void startActivity(Intent intent) {
        final String action = intent.getAction();
        if (action.equals(Intent.ACTION_VIEW)) { 
            // maybe also check if getScheme() is 'http' then set our flag
            persist.saveToPrefs("linkifyClick", true);
        }
    
        // proceed with normal handling by the framework
        super.startActivity(intent);
    }
    

    That other answer also show how you can call startActivityForResult() too instead if you want.

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

Sidebar

Related Questions

I think I need to put some code where the comment is (or maybe
What I think I need to do is create some code that lets me
I need to put together a piece of code that parses a possibly large
I have some php code that is creating an html table. Within it I
I don't think I need to post my code (there's lots of it) but
I think I might need to do something like the following pseudo-code in my
I have a custom PropertyItem that I've created and stored some values in within
I have a snippet of code where I first put some values in to
I have a some code that gets passed a class derived from a certain
in a C++ program I need some helper constant objects that would be instantiated

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.