how to ensure only after service(started in alarmreceiver) finish its job the alarm should be called again
<p>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:</p>

<pre><code>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);
}
}
</code></pre>

<p>and my Appservice</p>

<pre><code>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
            }


}
}
</code></pre>

<p>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</p>

<p>Thanks in advance</p>
