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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T04:57:23+00:00 2026-06-18T04:57:23+00:00

I have a service from which I instationate my ScreenReceiver class. How can I

  • 0

I have a service from which I instationate my ScreenReceiver class. How can I notify service when OnRecieve method of ScreenReceiver is triggered? I’d like the update() method to be called when ‘onRecieve` is trigerred.

StateChecker.java (draft):

public class StateChecker extends Service {
   //...
   // setting TimeAlarm
   TimeAlarm mTimeAlarm = new TimeAlarm();
   mTimeAlarm.SetAlarm(this.getApplicationContext(),10);

   public void update() {
   //update sth
   }
   //...
}

ScreenReceiver.java (draft):

public class ScreenReceiver extends BroadcastReceiver {
    //...   

   @Override
   public void onReceive(Context context, Intent intent) {
    //...
    PowerManager pm = (PowerManager) context.getSystemService(Context.POWER_SERVICE);
   }
    //...
}
  • 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-18T04:57:24+00:00Added an answer on June 18, 2026 at 4:57 am

    You can probably do something like this:

    Make a new Intent to your Service from the Receiver, passing off an Extra, then override onStartCommand() in the Service. Check the intent for the Extra, and if the Extra exists, call update().

    Also, if you use this instead of this.getApplicationContext(), it is very likely that your Receiver‘s onReceive() Context parameter will be the service. Then you can just cast.

    Eg

    if (context instanceof StateChecker)
      ((StateChecker) context).update();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In my WCF service I have implemented a custom encoder which inherits from System.ServiceModel.Channels.MessageEncoder
I have a windows service which fetches data from various datasources and build a
So I have wcf rest service which succesfuly runs from a console app, if
I have a WCF web service which is responsible for managing work sent from
I have a ReSTful web service which needs to parse locale-sensitive data from the
I have the following JSON coming back from a web service which I am
I have a service component (common task for all my apps), which can be
I have a third party service from which I'm getting a large collection of
I have a service in an application, and I can reach this service from
I have a web service from which I receive XML response. In jQuery I

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.