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

  • Home
  • SEARCH
  • 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 7721191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T03:51:42+00:00 2026-06-01T03:51:42+00:00

I have a problem with my BroadcastReceiver. Basically, I have a function in my

  • 0

I have a problem with my BroadcastReceiver. Basically, I have a function in my service, that I want to call every, let’s say, 2 hours. So I used the AlarmManager and Broadcast receiver to do it, however, it looks like the receiver is never called. My code:

in service’s onCreate method:

Intent intent5 = new Intent("MYINTENT");
sender2 = PendingIntent.getBroadcast(this, 192838, intent5, PendingIntent.FLAG_UPDATE_CURRENT);
am2 = (AlarmManager)this.getSystemService(Context.ALARM_SERVICE);
am2.setRepeating(AlarmManager.RTC_WAKEUP, Calendar.getInstance().getTimeInMillis(), 1000*60*60*2, sender2);

BroadcastReceiver connectionReceiver = new BroadcastReceiver() {
  @Override
  public void onReceive(Context context, Intent intent) {
       check();
    }
  };

  registerReceiver(connectionReceiver, new IntentFilter("MYINTENT"));

and then there’s the check() method

public static void check(){
    //some code
}

I’ve also tried to creat a class extending BroadcastReceiver, registering it in the Manifest etc, and it got called, but then I got a NullPointerException calling the service’s check() metheod from within the 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-01T03:51:43+00:00Added an answer on June 1, 2026 at 3:51 am

    I’ve also tried to creat a class extending BroadcastReceiver, registering it in the Manifest etc, and it got called, but then I got a NullPointerException calling the service’s check() metheod from within the BroadcastReceiver.

    Go back to that solution, then fix your NullPointerException. Most likely, Android terminated the process of your app that called registerReceiver() (e.g., user pressed HOME and did not return to the process). check() — whatever that is — has to assume that this is a brand-new process. Your NullPointerException probably comes from check() thinking that something should be initialized, when it is not.

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

Sidebar

Related Questions

I have problem with fancybox. I want to write a function that will run
I have an update service that starts at boot. The thing is I want
Basically, my problem is that i need to send data from my service (started
I have registered ProximityAlert in MapActivity. No problem with catching alerts in BroadcastReceiver and
I have problem with HTTP headers, they're encoded in ASCII and I want to
I have a program that monitors incoming SMS's, and I want it to monitor
I have a problem, not that major problem but since i implemented sendMultipartTextMessage on
Hello I faced the same problem I have 1 broadcast receiver from that I
I have some problem with BroadcastReceiver. There nothing happens when I catch an outgoing
I have a problem(again)...now i want to pass a String from one Activity to

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.