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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T00:43:55+00:00 2026-06-05T00:43:55+00:00

I have a broadcast receiver that will start an intent service to do some

  • 0

I have a broadcast receiver that will start an intent service to do some work on a separate thread.

I have tried digging into the Intent Documentation to find a way to obtain the context that is used to create the intent:

Intent(Context packageContext, Class<?> cls)

However the signature of on start command is the following and does not allow you to get to the context that is passed. I did not see a get context as a public method for intent, but I could have missed something.

public int onStartCommand(Intent intent, int flag, int startId)

Is there a way to get at the context that was used to create the intent without going the route of a second broadcast back the receiver to access the UI, or a handler.

  • 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-05T00:43:58+00:00Added an answer on June 5, 2026 at 12:43 am

    I have tried digging into the Intent Documentation to find a way to obtain the context that is used to create the intent

    Since that Context may not be in your process, that is not possible. Moreover, it is not necessary.

    Is there a way to get at the context that was used to create the intent without going the route of a second broadcast back the receiver to access the UI

    The BroadcastReceiver cannot update the UI. Hence, even if what you wanted was possible (which it is not), it would do you no good.

    Moreover, since you are kicking off an IntentService, you may not have a UI. The user is in control of their phone, and so they are perfectly welcome to leave your app and go to the home screen or another app.

    One pattern for dealing with this is to send an ordered broadcast from the IntentService. Have the activity implement a high-priority BroadcastReceiver for that broadcast, with a normal-priority receiver registered in the manifest. The latter would raise a Notification, so if your activity is not in the foreground, the user will see the Notification instead. Here is a blog post going into a bit more detail, and here is a sample application demonstrating this technique.

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

Sidebar

Related Questions

Can We only work with one broadcast receiver ? I have some broadcast receiver
I have a particular situation: a service started by a broadcast receiver starts an
I would like to start a broadcast receiver from an activity. I have a
I have an Android Service. When a phone boots up, a broadcast receiver receives
Hello I faced the same problem I have 1 broadcast receiver from that I
I have been trying to work out how to clear a broadcast receiver after
In my application, I have registered a broadcast receiver to receive the system intent
I need a service to start at boot that periodically checks some database for
I have an app that has one Broadcast Receiver that listens for a specific
I have a broadcast receiver that listens to incoming calls. And I want to

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.