-2
Comment puis-je rappeler mon service Android toutes les 10 secondes? Ceci est ma classe de service.Rappel des services Android
package com.example.vaccinationsystem;
import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;
import android.widget.Toast;
public class BackgroundServices extends Service{
private static final String TAG = "MyService";
@Override
public IBinder onBind(Intent arg0) {
return null;
}
@Override
public void onCreate() {
Toast.makeText(this, "Congrats! MyService Created", Toast.LENGTH_LONG).show();
Log.d(TAG, "onCreate");
}
@Override
public void onStart(Intent intent, int startId) {
Toast.makeText(this, "My Service Started", Toast.LENGTH_LONG).show();
Log.d(TAG, "onStart");
}
@Override
public void onDestroy() {
Toast.makeText(this, "MyService Stopped", Toast.LENGTH_LONG).show();
Log.d(TAG, "onDestroy");
}
}
Je l'appelle dans une autre classe par:
startService(new Intent(this, BackgroundServices.class));
Comment peut-il courir après toutes les 10 secondes.
Il y a un problème. Il va créer le service à chaque fois. Je veux juste commencer. ? –