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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:08:50+00:00 2026-06-11T08:08:50+00:00

My broadcast receiver is Still getting execute even if My application is not working.

  • 0

My broadcast receiver is Still getting execute even if My application is not working.

as an example I am using android.intent.action.NEW_OUTGOING_CALL to check outgoing call and than i stop music and push notification ..
but even i close my app and kill all task and after if i call than i get notification of my app..
So how do i manage to work my broadcast when i am using my app.
I have crated Service to play music and 2 broadcast receiver file for incoming and outgoing.
Help to solve this problem.

Also How can i destroy my app with service running behind If user press exit button.
**Update I made edited it and its working now fine..thank you so much you all

here is my code

<activity
        android:name=".MainActivity"
        android:label="@string/title_activity_main"
        android:launchMode="singleTask">
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />


            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
          </activity>

    <receiver android:name="OutgoingCallInterceptor">                          
        <intent-filter android:priority="1">                                  
            <action android:name="android.intent.action.NEW_OUTGOING_CALL" />  
        </intent-filter>
    </receiver>

    <receiver android:name="IncomingCallInterceptor">                          
        <intent-filter android:priority="1">                                  
            <action android:name="android.intent.action.PHONE_STATE" />  
            <action android:name="android.media.AUDIO_BECOMING_NOISY" />

        </intent-filter>
    </receiver>

Update
as you all suggest me i have made receiver into main class file and register it from there but it wont work

public class MainActivity extends Activity {
RemoteViews layout;
int SDK_INT;
 BroadcastReceiver br;
 @Override
    protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
     IntentFilter filter = new IntentFilter("android.media.AUDIO_BECOMING_NOISY");
     this.registerReceiver(br, filter);
     setContentView(R.layout.activity_main);
         SDK_INT = android.os.Build.VERSION.SDK_INT;
        System.out.println(SDK_INT);
        Button start = (Button)findViewById(R.id.play);
        Button stop = (Button)findViewById(R.id.stop); 
        start.setOnClickListener(startListener);
        stop.setOnClickListener(stopListener);
        br = new BroadcastReceiver() {  
            @Override
            public void onReceive(Context context, Intent intent) {
                // TODO Auto-generated method stub
                 if (intent.getAction().equals(android.media.AudioManager.ACTION_AUDIO_BECOMING_NOISY)) {
context.stopService(new Intent(context, myPlayService.class));
                        Toast.makeText(context, "Headphones disconnected.", Toast.LENGTH_SHORT).show();
                 }
            }  }
        };

@Override   
protected void onDestroy() {
    super.onDestroy();
    unregisterReceiver(br);
}
  • 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-11T08:08:52+00:00Added an answer on June 11, 2026 at 8:08 am

    an example: how a broadcast reciver can be registered and un registered change as per your need “i hope the code is self explanatory”

     private final BroadcastReceiver xyz= new BroadcastReceiver() {
    @Override
    public void onReceive(Context context, Intent intent) {
        String action = intent.getAction();
    //ur reciver
     }
      protected void onCreate(Bundle savedInstanceState) {
     super.onCreate(savedInstanceState);
    
    IntentFilter filter = new IntentFilter(ACTION);//ur action
    this.registerReceiver(xyz, filter);
    }
    
    @Override
    protected void onDestroy(){
    super.onDestroy();
    unregisterReceiver(xyz);
     }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created Broadcast receiver <receiver android:name=.IncomingBroadcastReceiver> <intent-filter> <action android:name=android.intent.action.PHONE_STATE></action> </intent-filter> </receiver> declared it
I am using sms broadcast receiver in my application. When i send first sms
I am using an broadcast receiver for Intent.ACTION_BATTERY_CHANGED. Rate at which I receive this
Does anyone know why my application still receives the ACTION_BOOT_COMPLETED broadcast even when my
I have a simple broadcast receiver set to receive system intents informing my application
I am sending intent to a broadcast receiver like this. Intent cpIntent = new
My application has a static broadcast receiver that listens to specific data sms on
I have a boot complete broadcast receiver but it wasnt working as expected. Nor
I have an SMS broadcast receiver in my application with a static boolean value
I'm using C2DM in my application, and I have a receiver, which sends data

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.