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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:59:29+00:00 2026-06-17T05:59:29+00:00

I am trying to execute a service in the background. This service is started

  • 0

I am trying to execute a service in the background. This service is started on boot and its function is to execute something every 8 hours. In this case it sends a file by mail using JavaMail API and gmail account. This is my code:

private Handler mHandler;
private Runnable updateRunnable = new Runnable() {
    @Override public void run() {
        new MailSenderActivity.MailSender().execute();


        queueRunnable();
    }
};

private void queueRunnable() {


    mHandler.postDelayed(updateRunnable, 28800000); 
}

@Override
public IBinder onBind(Intent intent) {
    return null;
}

@Override
public void onCreate() {

    mHandler = new Handler();
    queueRunnable();       
}

@Override
public void onDestroy() {
    //code to execute when the service is shutting down
}
@Override
public void onStart (Intent intent, int startid) {
    //code to execute when the service is starting up
}

If xxxx in mHandler,postDelayed(updateRunnable, xxxx) is 600000 (10 minutes in milliseconds), it runs perfectly, but it doesn’t if it is 28800000 (8 hours in milliseconds)

Any suggestions?

Thanks in advance

  • 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-17T05:59:31+00:00Added an answer on June 17, 2026 at 5:59 am

    I am trying to execute a service in the background. This service is started on boot and its function is to execute something every 8 hours.

    Please don’t do that. Please use AlarmManager to start an IntentService every 8 hours. That way, your service does not have to stay around in memory all that time.

    If “xxxx” in “mHandler,postDelayed(updateRunnable, xxxx)” is 600000 (10 minutes in milliseconds), it runs perfectly, but it doesn’t if it is 28800000 (8 hours in milliseconds)

    Quite possibly, Android terminated your process. Again, this is not a problem if you use AlarmManager and an IntentService.

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

Sidebar

Related Questions

I'm facing a problem trying to fetch data by the background service started at
I'm trying to start an activity from a service running in background but its
Im trying to execute a .bat file remotely in a powershell script. The code
I'm trying to execute command prompt commands and read the output in C#. This
I am trying to debug web service call which uses JMS in the background.I
I'm trying to execute a .bat script in a C# windows service but it
I'm trying to execute a 3rd party application, called from a .cmd batch file,
I am very knew to Knockoutjs and I am trying to execute a service
I am trying to execute a command like this from a Ruby on Rails
I am trying to execute a install activeMq service from powershell, for which 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.