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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:01:03+00:00 2026-06-15T23:01:03+00:00

I have a service that look gps coordinate. I want that when the user

  • 0

I have a service that look gps coordinate. I want that when the user click on the home button the gps stop to work (battery saving).

The strategy i am using is this:

    @Override
public void onPause() { 
    super.onPause();
    doUnbindService();
}

@Override
public void onResume() {
    super.onResume();
    doBindService();  
}

on each Activity that use the service. The problem is that each time i switch activity it stop and resume. Is there a strategy that let me have the service always up until my app is in foregroung?

  • 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-15T23:01:05+00:00Added an answer on June 15, 2026 at 11:01 pm

    I have an app with 3 activities that use a service to deal with the GPS. In each activity’s onStart() I have code of the form

    bindService(new Intent(..., ..., Context.BIND_AUTO_CREATE);
    

    and in each onStop() I have

    unbindService(..);
    

    You should find that activity 2’s onStart() will execute before activity 1’s onStop(). Thus only when no activities are running will the service stop.

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

Sidebar

Related Questions

I currently have service classes that look something like this public class UserService :
I have this restfull service that I want to be able to call for
I have application that look like below without spring (prior) UI-> service --> javabean
In the service layer I have a classes that look something like: class MyService
I have a service that performs a slow task, when its finished I want
I have a RIA Services data service that has several function calls that look
Ok so I have two objects that look like this in my WCF service.
I have some web methods in an asmx web service that currently look like
I have a WCF Service that I want to process one request from all
I have a Service that sends an Intent to my Activity every 0.1 seconds.

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.