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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T06:00:15+00:00 2026-06-16T06:00:15+00:00

Hi folks how I can implement a Broadcast receiver in an activity that receives

  • 0

Hi folks how I can implement a Broadcast receiver in an activity that receives intent from a service along with some parameter’s of int and string type?

UPDATE:

I have this under the Activity:

 private BroadcastReceiver ReceivefrmSERVICE = new BroadcastReceiver(){

    @Override
    public void onReceive(Context context, Intent intent) {

        Toast.makeText(context, "IN DA BroadCASTER",
                Toast.LENGTH_LONG).show();

    }

   };

and I have this under a function in the service that is called on a event from another activity when a checked button is checked:

 public void switchSpeaker(int hr, int min){

       Toast.makeText(Server.this, hr +" , " +min, Toast.LENGTH_LONG).show();

       Intent intent = new Intent(this, andRHOME.class);
       //intent.putExtra("sendMessage","1");
        startActivity(intent);
        /*PendingIntent pi = PendingIntent.getService(Server.this, 0, myIntent, 0);
        AlarmManager almmgr = (AlarmManager) getSystemService(ALARM_SERVICE);
        Calendar cldr = Calendar.getInstance();
        int min1 = cldr.get(Calendar.MINUTE);
        cldr.setTimeInMillis(System.currentTimeMillis());
        cldr.add(Calendar.SECOND, 30);
        almmgr.set(AlarmManager.RTC_WAKEUP, cldr.getTimeInMillis(), pi);*/
    }

But its crashing?? ,What to do?

  • 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-16T06:00:17+00:00Added an answer on June 16, 2026 at 6:00 am
    BroadcastReceiver receiver = new BroadcastReceiver() {
        @Override
        public void onReceive(Context context, Intent intent) {         
           // DO YOUR STUFF
        }
    }
    
    IntentFilter filter = new IntentFilter();
    

    in onResume: (so you receive only while in foreground)

    filter.addAction(/* the action you want to receive */);
    registerReceiver(receiver, filter);
    

    in onPause: (the try catch is to fix a bug in unregister in case it is called twice)

    try {
        unregisterReceiver(receiver);
    } catch (IllegalArgumentException e) {
        if (e.getMessage().contains("Receiver not registered")) {
            // Ignore this exception. This is exactly what is desired
            Log.w(TAG,"Tried to unregister the reciver when it's not registered");
        } else {
            // unexpected, re-throw
            throw e;
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hi folks can we upload photos from phone`s camera just with pure HTML5? Can
I'm seeing something that's got me stumped. Maybe you folks can advise. What appears
Folks. I just can't make the jump from the Haystack tutorial/docs to my (simple)
Folks, The project that I am working on requires that a certain video can
I still feel a bit unsafe about the topic and hope you folks can
Folks, is there somewhere on the Net where I can find a list of
Folks I am surprised to see my code working, that I dont have any
Folks, We are developing an application that is part a downloadable WinForms application that
Folks, I really like the -Wshadow option since it helps to spot some possible
I need to implement an ArrayList which can hold like person records. I can

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.