Answer the question
In order to leave comments, you need to log in
Why are requests looping?
Hello everyone, please help me figure out one thing, the application uses retrofit2, with its help I make a head request to the server
ShoppingService service = ServiceGenerator.createServiceToken(ShoppingService.class, token);
Call is_update_request = service_gen.is_update();
Headers headers = is_update_request.execute().headers();
@HEAD("shoplists_update/")
Call<Void> is_update();
@Override
protected void onHandleIntent(Intent intent) {
String token = getToken();
ShoppingService service = ServiceGenerator.createServiceToken(ShoppingService.class, token);
Log.d(LOG_TAG, "onHandleIntent start ");
try {
Log.v(LOG_TAG, "start request");
if(is_sync(service)){
Log.v(LOG_TAG, "start sync");
sync(service);
Log.v(LOG_TAG, "end sync");
}
} catch (IOException | ParseException e) {
e.printStackTrace();
}
Log.d(LOG_TAG, "onHandleIntent end ");
}
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_shopping_list);
AlarmManager mgr = (AlarmManager) this.getSystemService(Context.ALARM_SERVICE);
Intent notificationIntent = new Intent(this, SyncService.class);
PendingIntent pendingIntent=PendingIntent.getService(this, 0, notificationIntent, 0);
mgr.setInexactRepeating(AlarmManager.RTC_WAKEUP,
System.currentTimeMillis(), 120, pendingIntent);
}
Answer the question
In order to leave comments, you need to log in
From what I understand, your problem is that you are setting an "alarm" every time onCreate() is called. You need somewhere (for example, Preferences) to remember what you have already set.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question