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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:09:46+00:00 2026-06-16T03:09:46+00:00

I’m developing an app that makes asynchronous calls to server for notifications. Everything works

  • 0

I’m developing an app that makes asynchronous calls to server for notifications. Everything works fine in the main activity. Now what’s bothering me, that i need a service that would poll for notifications when the app is not active (just like GMail stock app). So I start remote service in another process in the main activities onStop function like that:

@Override
public void onStop() {
    super.onStop();
    if(prefs.getBoolean(OPTIONS_KEY_SERVICE, false)) {
        startServiceIntent = new Intent(CloudAlarmsService.MY_SERVICE);
        Bundle b = new Bundle();
        b.putStringArray("duidCodes", duidCodes);
        startServiceIntent.putExtras(b);
        Log.d("SSE_SERVICE", "Starting Service");
        startService(startServiceIntent);
    }
}

It works fine, i get notifications after the activity was closed. Now i would like to stop remote service on activity start (so i won’t have activity and service polling server concurrently). I do it like this:

@Override
public void onResume() {
    super.onResume();
    stopService(new Intent(CloudAlarmsService.MY_SERVICE));
    Log.d("SSE_SERVICE", "Stopping service");
}

CloudAlarmsService.MY_SERVICE is a string in my service class:

public class CloudAlarmsService extends Service {
    public static String MY_SERVICE = "cloudindustries.alarms.service.BACKGROUND_SERVICE";
...

and also it is declared in manifest xml like that:

<service android:process=":alarms_poller" android:name=".CloudAlarmsService">
     <intent-filter android:label="@string/serviceStopService">
           <action android:name="cloudindustries.alarms.service.BACKGROUND_SERVICE" />
     </intent-filter>
</service>

But service is not stopped and it keeps working. After i close the main activity another instance of service spawns and continues polling.

Is there something i am missing out?
Or maybe this is a bad use for a remote service or even there is another type of service / manager which could be used for such purpose?

Thanks for any help!

Edit:

Question clarification: Is it possible to stop remote service from different activity (which did not start the service)?

  • 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-16T03:09:47+00:00Added an answer on June 16, 2026 at 3:09 am

    try to stop CloudAlarmsService service as:

    Intent intent = new Intent();
    intent.setClass(getApplicationContext(), CloudAlarmsService.class); 
    getApplicationContext().stopService(intent);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build

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.