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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T10:25:01+00:00 2026-05-16T10:25:01+00:00

I have an application that listens for screen off, and user present intents. Since

  • 0

I have an application that listens for screen off, and user present intents. Since you cant register to receive screen off intents from the manifest, I am registering them in a service.

Do I really need to have a whole service to ensure that I always get notified of when the screen shuts off, and the user unlocks the phone? Seems really wasteful 🙁

The code I use in my service:

@Override
public void onCreate() {
    super.onCreate();
    Log.d(TAG, "Service created.");
    // register receiver that handles user unlock and screen off logic
    IntentFilter filter = new IntentFilter(Intent.ACTION_USER_PRESENT);
    filter.addAction(Intent.ACTION_SCREEN_OFF);
    BroadcastReceiver mReceiver = new ScreenReceiver();
    registerReceiver(mReceiver, filter); 
}
  • 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-16T10:25:02+00:00Added an answer on May 16, 2026 at 10:25 am

    Please consider what you are broadly trying to do, and a different way to do it.

    Yes, the only way to monitor the events is to be actively registered. This is very intentional, because they are a very tempting thing for applications to think they want to be told about, and ending up with a bunch of apps having to be launched each time the user turns their screen on or off would end up with a really bad user experience.

    Given that, I can tell you right now that there is no way you can guarantee that you will see these events, besides using a service that is always running and has used startForeground() to prevent itself from being killed. Obviously, this is not something you want to do unless your app is doing something the user very deliberately cares about having running for them when they decide it should be.

    So… what are you trying to accomplish?

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

Sidebar

Related Questions

I have an application that runs (listens to incoming TCP data) from the command
I have an application that listens on a port for information from scripts on
I have an application that listens to a piece of hardware on a USB
I have an application that sends broadcast messages and listens for response packets. Below
I have a server application that binds to a port and listens on it.
I've written an application in Swing that listens for UDP packets from a smart
I have a BlackBerry application that needs to take pictures from the camera and
I have an application that is running as a background service and constantly listens
I have server application that listens for clients. Let's client lost internet connection and
Let's say you have an application that listens on a socket on all network

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.