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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T21:14:23+00:00 2026-05-26T21:14:23+00:00

I have a widget and I would like to check if the screen is

  • 0

I have a widget and I would like to check if the screen is off or on.

I can’t use PowerMananger.isScreenOn because I want to support Android 1.5/1.6 .

So I tried to register SCREEN_ON/SCREEN_OFF actions in the manifest but that doesn’t work. Seems like only registerReceiver works for those intents. (Android – how to receive broadcast intents ACTION_SCREEN_ON/OFF?)

The question is, where should I register my widget?

I can’t register the screen intents receiver from my widget because you can’t call registerReceiver from another BroadcastReceiver that is stated in the manifest.

I thought about calling it in the onCreate of my configuration activity.

The problem is that I don’t call unregisterReceiver, so I get an exception for a leak.

Is there any other solution to this?

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-26T21:14:24+00:00Added an answer on May 26, 2026 at 9:14 pm

    My solution is to start a service in the public void onReceive(Context context, Intent intent) method in the AppwidgetProvider subclass. Like:

            if (intent.getAction().equals(AppWidgetManager.ACTION_APPWIDGET_ENABLED)) {
            Intent listenerService=new Intent(context,ScreenMoniterService.class);
            startService(listenerService);
            return;
        }
    

    Then in the public void onCreate() method of this service, register the BroadcastReceiver and in the public void onDestroy() method, unregister it.
    Of course, you should stop that service when all of the appwidget are deleted.

            if (intent.getAction().equals(AppWidgetManager.ACTION_APPWIDGET_DISABLED)) {
    
            Intent listenerService=new Intent(context,ScreenMoniterService.class);
            stopService(listenerService);
            return;
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a widget running under android and I would like for it to
I am targeting 1.6 but I would like to have nice widget that can
I build a composite widget and would like it to have it's own accelerators
can a widget have a marquee textview? if so how would i implement it?
I'm using JQuery UI's autocomplete widget and would like to have access to the
I have a combobox widget in python that I would like to be able
I have a widget that displays a set of information. What I would like
Here is what I would like to do. Say I have Class Widget. I
I have a widget that I've added to a FlexTable. I would like to
I have a custom widget that is actually an image, and i would like

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.