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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T13:27:38+00:00 2026-05-19T13:27:38+00:00

I have a Service that can be stopped in multiple ways. Whenever I call

  • 0

I have a Service that can be stopped in multiple ways. Whenever I call stopService(Intent), I pass an intent with some extras. How do you retrieve those extras?

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-19T13:27:39+00:00Added an answer on May 19, 2026 at 1:27 pm

    You need to override onStartCommand() in your Service this is how you get a reference to the incoming intent from startService.

    In this case you would have a special action in your intent to tell the service to stop itself. You add extras to this intend which can be read in the onStartCommand() method.

    Sample Code

    public class MyService extends Service {
        @Override
        public int onStartCommand(final Intent intent, final int flags, final int startId) {
             final String yourExtra = intent.getStringExtra(YOUR_EXTRA_ID);
             // now you can e.g. call the stopSelf() method but have the extra information
        }
    }
    

    Explanation

    Every time you call context.startService(Intent) onStartCommand() will be called. If the service is already running a new service isn’t created but onStartCommand is still called. This is how you can get a new intent with extras to a running service.

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

Sidebar

Related Questions

I have a service that can be started and stopped from a button .
I have my main activity that can bind a service and call a service
I have a web service that I can only hit if I'm logged into
I have an ASP.NET web service that I can access via a windows program
I hope you can help me. I have a web service that needs to
We have a service that has some settings that are supported only over net.tcp.
I have a single service installer project that installs multiple services. This is great
I have created a Windows Service that will be calling out to some COM
I have a couple old services that I want to completely uninstall. How can
We have a service that runs methods used for data import/export at specified intervals.

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.