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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:30:20+00:00 2026-06-14T21:30:20+00:00

I want to make an timer which starts counting when the Android device is

  • 0

I want to make an timer which starts counting when the Android device is woken up and stops when the Android device is set to sleep. I found nothing, how a activity could be triggered
by wake up/sleep.

I hope you can help me with my problem

  • 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-14T21:30:22+00:00Added an answer on June 14, 2026 at 9:30 pm

    I used a BroadcastReceiver like timonvlad said but ACTION_SCREEN_ON and ACTION_SCREEN_OFF could not be called by XML so I created an service. The service has to be registered in the XML then I used this code

    public class OnOffReceiver extends Service {
    
    @Override
    public IBinder onBind(Intent arg0) {
        // TODO Auto-generated method stub
        return null;
    }
    
    @Override
    public int onStartCommand(Intent intent, int flags, int startId) {
        registerReceiver(new BroadcastReceiver() {
    
            public void onReceive(Context context, Intent intent) {
                            //This happens when the screen is switched off
              }
            }, new IntentFilter(Intent.ACTION_SCREEN_OFF));
    
    
        registerReceiver(new BroadcastReceiver() {
    
              public void onReceive(Context context, Intent intent) {
                              //This happens when the screen is turned on and screen lock deactivated
              }
            }, new IntentFilter(Intent.ACTION_USER_PRESENT));
    
        return START_STICKY;
    }
    
    @Override
    public void onDestroy() {
        super.onDestroy();
    }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to make a Windows Form Application which only shows a timer as:
I want to make a time or date listener which for example invoke an
I want to make timer string with CCLabelAtlas. The problem is the character, :.
I'm messing around with Xcode and Interface Builder. I want to make a timer
I want to make a WCF timer service where clients can register in order
I'm paid by the hour and I want to make an app which I
Is this possible in an Android app? I want to make it so that
I want to make an application which has auto start option in its settings.
What I want to do, is to make a bash script, which at one
I want to make the time of each post to change in realTime. This

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.