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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T19:01:54+00:00 2026-05-31T19:01:54+00:00

I have on Service that must communicate with an Activity (MyActivity) through a BradcastReceiver.

  • 0

I have on Service that must communicate with an Activity (MyActivity) through a BradcastReceiver. This BroadcastReceiver is declare intosame activity so :

    private class MessaggiReceiver extends BroadcastReceiver {
        public static final String ACTION_RELOAD = "it.android.dev.thecode.ACTION_RELOAD";
        @Override
        public void onReceive(Context arg0, Intent intent) {
            if(intent.getAction().equals(ACTION_RELOAD)){
                leggi_act; //Method of MyActivity
            }
        }

    }

but how must declare into Manifest the brodcast contained within the MyActivity ? I used this code with it.android.dev.thecode.MyActivity.MessaggiReceiver

<receiver android:name="it.android.dev.thecode.MyActivity.MessaggiReceiver">
            <intent-filter>
                <action android:name="it.android.dev.thecode.ACTION_RELOAD"></action>
            </intent-filter>
</receiver>

but is wrong then I used this code with it.android.dev.thecode.myactivity$MessaggiReceiver

<receiver android:name="it.android.dev.thecode.MyActivity$MessaggiReceiver">
                <intent-filter>
                    <action android:name="it.android.dev.thecode.ACTION_RELOAD"></action>
                </intent-filter>
    </receiver>

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-31T19:01:55+00:00Added an answer on May 31, 2026 at 7:01 pm

    You don’t need to register a broadcast receiver in your manifest, instead register it by code in your activity’s onResume. Don’t forget to unregister in onPause to avoid any leaks.

    @Override
    public void onResume() {
       registerReceiver(mMessageReceiver,
           new IntentFilter("it.android.dev.thecode.ACTION_RELOAD"));
    }
    
    @Override
    public void onPause() {
       unregisterReceiver(mMessageReceiver);
    }
    
    private BroadcastReceiver mMessageReceiver = new BroadcastReceiver() {
      @Override
      public void onReceive(Context context, Intent intent) {
        Log.d("receiver", "Got broadcast: " + intent.getAction());
      }
    };
    
    • 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 sends an Intent to my Activity every 0.1 seconds.
I have a service that use the tcp binding and this services allows to
I have a web service that must run an executable. To run the executable
The official documentation says that Your application must have a local Service to facilitate
I have a service and its behavior must change when topmost Activity changes. Say,
I have a Windows Service that must connect, via VPN, to the network in
I have a service (with a wakelock) that must run continuously behind the scenes
I have a service that runs a TimerTask in a method, which must count
Ok I have a big problem here. I have a service that must accest
I have a service that is defined as: public class SleepAccelerometerService extends Service implements

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.