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

  • Home
  • SEARCH
  • 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 7611565
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T01:41:36+00:00 2026-05-31T01:41:36+00:00

My question is… If we try to execute some code after startActivity() will it

  • 0

My question is… If we try to execute some code after startActivity() will it we fully executed before the onPause() of the current Activity is called? That is, I do not know if startActivity() will actually be called when the method that contains it reaches the end (something that happens with the finish() method).

I have an example in which I want to detach() an object (that has a Database connection) after a new Activity is started based on some conditions, but I need this object to evaluate one condition. I know I could check that condition and store the boolean value and detach() it before the first if, but I would like to know if the following code is “legal”.

Thanks!

protected void onListItemClick(ListView l, View v, int position, long id) {
    super.onListItemClick(l, v, position, id);
    School selectedSchool = new School((Cursor)l.getItemAtPosition(position));
    mSharedPreferences.edit()
    .putLong(DatabaseManager.SCHOOL_ID, selectedSchool.getIdOpenErp())
    .commit();
    School.SchoolManager schoolManager = new School.SchoolManager(this);
    Long[] sessionIdsOpenErpOfSelectedSchool = schoolManager.getSessionIdsOpenErp(selectedSchool);
    if (sessionIdsOpenErpOfSelectedSchool.length > 0) {
        if (schoolManager.isPreviousWorkingSchoolPresent()) { // line 10
            Intent iParticipationManagement = new Intent(this, ParticipationManagement.class);
            startActivity(iParticipationManagement);
        } else {
            Intent iSelectExistingSession = new Intent(this, SelectExistingSession.class);
            startActivity(iSelectExistingSession);
        }
    } else {
        Intent iSelectNewSession = new Intent(this, SelectNewSession.class);
        startActivity(iSelectNewSession);
    }
    // The following line will be executed after one of the startActivity() methods is called...
    // Is this legal? Or should I get the value from isPreviousWorkingSchoolPresent() (at line 10)
    // before the first if and do the detach() there as well?
    schoolManager.detach();
}
  • 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-31T01:41:37+00:00Added an answer on May 31, 2026 at 1:41 am

    Anything you want execute in the method with the call to startActivity() will get executed before you receive a call to onPause(). The thing is, your application by default uses one main thread, calls to onPause() and other lifecycle methods happen on it. So while this thread is busy with executing the code in your method, it can’t process anything else.

    This would only be a problem if your method were executed in some other thread. This is not the case, however, since this method is used to listen to UI events, so I assume that it is always called from the main thread.

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

Sidebar

Related Questions

Question Is there a way to have a method that will always run anytime
Question for the video tag, the following code works for every browsers expect opera
Question explains it all really, I need to add some text to a PDF
(Question updated after first comment) int max_size = 20; int h[max_size]; Debugging gives a
Question: I have one popup window it contains some values in textbox and textarea.
Question What's the full code to enable jQuery on a page and then use
Question: I want to populate a LINQ table from code, not DataBase. Is it
Question is not correctly framed i know, how do i code the below logic
Question: Can I override default functions in Javascript? Background: After figuring out that I
Question 1: Why not change pagination after click (pagination page change but it no)?

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.