Android: Démarrer le Service avec le Contexte.startService vs PendingIntent.la méthode getService

Contexte.startService

Intent intent = new Intent(context, MyService.class);
context.startService(intent);

PendingIntent.la méthode getService

Intent intent = new Intent(context, MyService.class);
PendingIntent pi = PendingIntent.getService(context, 0, intent, 0);
pi.send();

Questions

  1. Quand souhaitez-vous commencer un service de Contexte.startService vs un PendingIntent?
  2. Pourquoi voudriez-vous utiliser un sur l'autre?

OriginalL'auteur Metro Smurf | 2012-02-05