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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T08:13:12+00:00 2026-05-27T08:13:12+00:00

My application calls a few web services when it is freshly launched. I would

  • 0

My application calls a few web services when it is freshly launched. I would also like to call these web services if the user launches the app (which was running in the background) and resumes. I’ve looked into all the methods fired when apps are launched and when activities are in focus. onStart(), onResume(), onRestart() etc….

I thought onRestart would be a good bet to make my web service calls and update my view, problem is if I go from activity A (the one making the calls) to activity B and hit the back button, activity A will fire onRestart() and call the web services. I don’t want this to happen everytime I go back to my main screen from some activity in my app. I only want the services to be called if my app activity A is brought into focus from the outside. Are their any other events I should be aware of that could help me? If I hit the home button and then hit my app icon it should update, but not if I click something on my main screen, opening a new activity and then hit the back button.

Hope the question makes sense.

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-05-27T08:13:13+00:00Added an answer on May 27, 2026 at 8:13 am

    According to the Activity lifecycle, onRestart will be called before onResume. So if you put your web calls in onResume, it will be called when the activity first starts and any time it resumes. onRestart is only called when the user navigates back to that activity. So you can have a boolean in your activity (ex. boolean isActivityRestarting) that is set to false, then set to true in onRestart. If it’s true when onResume is hit, then don’t do your web calls.

    Example code:

    public void onRestart() {
        isActivityRestarting = true;
    }
    
    public void onResume() {
        if (!isActivityRestarting) {
            executeWebCalls();
        }
    
        isActivityRestarting = false;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm working on an iPhone application that makes a few calls to web services.
I've a few web methods that I use to call some external services like
I have an ASP.NET application that calls other web services through SSL (outside the
Our application is interfacing with a lot of web services these days. We have
We have a .NET application that makes several concurrent calls to various web services,
Upon launching my application, a few web service calls are made to check for
I have an application that calls a number stored by the user. Everything works
I've the following issue I've a windows application It calls a remote web service
We are having a business logic which involves call to services. The application is
I've got an MVC solution that hosts a few routes for Web API services.

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.