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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:00:07+00:00 2026-05-29T05:00:07+00:00

I am trying to start up a BroadcastReceiver within a Service . What I

  • 0

I am trying to start up a BroadcastReceiver within a Service. What I am trying to do is have a background running service going that collects incoming text messages, and logs incoming phone calls. I figured the best way to go about this is to have a service running that incorporates a broadcast receiver that can catalog either.

How do i go about doing this? I already have my service up and running.

  • 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-29T05:00:08+00:00Added an answer on May 29, 2026 at 5:00 am

    as your service is already setup, simply add a broadcast receiver in your service:

    private final BroadcastReceiver receiver = new BroadcastReceiver() {
       @Override
       public void onReceive(Context context, Intent intent) {
          String action = intent.getAction();
          if(action.equals("android.provider.Telephony.SMS_RECEIVED")){
            //action for sms received
          }
          else if(action.equals(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED)){
               //action for phone state changed
          }     
       }
    };
    

    in your service’s onCreate do this:

    IntentFilter filter = new IntentFilter();
    filter.addAction("android.provider.Telephony.SMS_RECEIVED");
    filter.addAction(android.telephony.TelephonyManager.ACTION_PHONE_STATE_CHANGED);
    filter.addAction("your_action_strings"); //further more
    filter.addAction("your_action_strings"); //further more
    
    registerReceiver(receiver, filter);
    

    and in your service’s onDestroy:

    unregisterReceiver(receiver);
    

    and you are good to go to receive broadcast for what ever filters you mention in onCreate. Make sure to add any permission if required. for e.g.

    <uses-permission android:name="android.permission.RECEIVE_SMS" />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to start service from AsyncTask but cant see that its starts.
Im trying to start a wxPython app that (I have converted to an exe
I have a setup where I am running a background service in Android with
I am trying to start the main activity from inside a BroadcastReceiver. I dont
My aim is to start a service that listens for changes to the device's
I am trying to start a Gui tray application from a windows service (LocalSystem)
I am trying to start my VPN connection (using VPNC) from PHP. I have
I am trying to write a service that runs on phone boot, and must
I am trying to start an activity at device bootup. Stranege thing is that
I'm trying to start a service after the device has been started. The problem

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.