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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T18:36:55+00:00 2026-06-12T18:36:55+00:00

I have a broadcast receiver in my application. When I receive a broadcast I

  • 0

I have a broadcast receiver in my application.
When I receive a broadcast I pass the content to a service to decode it.

public class Receiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
    if (intent.getAction().equals("xxx.yyy.zzz")) {
        Log.d("Receiver", "Intent received from server!");

        byte[] data = intent.getByteArrayExtra("Data");
        String params = intent.getStringExtra("Params");

        Intent i = new Intent(context, DecodeService.class);
        i.putExtra("Data", data);
        i.putExtra("Params", params);

        context.startService(i);
    }
  }
}

Depending on the content, I start an appropriate activity from this service.

Now I have some questions about how to manage this service.

  • Where should I stop this service? Should I stop it after starting an activity from it and start it again when I receive a broadcast? Or should I let it run while the application is active and stop it when the application is exited.

  • What would be the advantage of binding to this service? And can I bind to a service from a broadcastreceiver?

  • 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-12T18:36:56+00:00Added an answer on June 12, 2026 at 6:36 pm

    Seems like you are using Service just to decode and start an Activity. Instead, I would suggest you to ditch the service part and try to accommodate decoding and launching your activity from the BroadcastReceiver class.

    For simple tasks, dont get involved with services. It will be a lot easier to expect your application’s behavior when not using services.

    In case you really want to use service, then I would suggest you to read about IntentService. It is also a type of service which runs in the background, does its job on a separate thread and automatically gets killed at the end.

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

Sidebar

Related Questions

I have this Broadcast receiver registered public class NotifyAlarmBroadcast extends BroadcastReceiver{ public Context context;
I have a Sms Broadcast Receiver class that extends broadcastreceiver to handle incoming sms,
I have a simple broadcast receiver set to receive system intents informing my application
In my application, I have registered a broadcast receiver to receive the system intent
I have an class as below: public class FYPSmsReceiverBroadcast extends BroadcastReceiver I need to
I have a broadcast receiver which receive an internet state changes. I want to
I have a particular situation: a service started by a broadcast receiver starts an
I have an SMS broadcast receiver in my application with a static boolean value
I have an Android Service. When a phone boots up, a broadcast receiver receives
I have to write a simple mobile application that is able to receive broadcast

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.