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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T19:00:57+00:00 2026-05-22T19:00:57+00:00

I have a alarm receiver start a service for every 5 mins. In the

  • 0

I have a alarm receiver start a service for every 5 mins. In the service Iam synching my database with a server. if the server splits the packets and send. I need to send the request again with a session id. The problem is when i do that i want the alarmreciever to wait until the service finish its work. ie only when i get all the packets the next 5mins should be counted. my alarm receiver:

public class OnBootReceiver extends BroadcastReceiver {
private static final int PERIOD = 60000;    // 1 minute 300000 for 5 min

@Override
public void onReceive(Context context, Intent intent) {
    AlarmManager mgr=(AlarmManager)context.getSystemService(Context.ALARM_SERVICE);
    Intent i=new Intent(context, OnAlarmReceiver.class);
    PendingIntent pi=PendingIntent.getBroadcast(context, 0,i, 0);
    mgr.setRepeating(AlarmManager.ELAPSED_REALTIME_WAKEUP,SystemClock.elapsedRealtime()+60000,PERIOD,pi);
}
}

and my Appservice

public class AppService extends WakefulIntentService {

public AppService() {
    super("AppService");
}

@Override
protected void doWakefulWork(Intent intent) {

    //connecting to server and getting data here.
    Log.v(null, "wake up");
            ...
            while (syncstaus.equals("more"){
            // send request again
            }


}
}

only after the loop finishes i want the alarm to start again. how can i do this. please throw some light on how this works

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-05-22T19:00:58+00:00Added an answer on May 22, 2026 at 7:00 pm

    Don’t set your alarm repeating.

    Consider two options :

    1) the service itself, after its job could ask the alarm manager to set a new alarm at fixed time

    2) use handler.postDelayed to do that instead of alarm manager. I find more flexible.

    Regards,
    Stéphane

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

Sidebar

Related Questions

I have an Android Service. When a phone boots up, a broadcast receiver receives
I start a service using alarm manager using button click. It is working too.
I have an alarm manager that starts a broadcast receiver. Here is my broadcast
In mainactivity I have Broadcast Receiver, pending intent, and alarm manager. It triggers as
I have a receiver that start after phone boot like this: <receiver android:name=.OnBootReceiver >
I have a background service which sets a repeating alarm, does its task and
I have an alarm set to trigger every n minutes, and it works fine.
I'm trying to set up an alarm receiver right after booting. Therefore, i have
I have searched a lot and always find that alarm manager always start with
I have an AlarmReceiver class which executes when alarm rings at a particular time

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.