Home | History | Annotate | Download | only in fakes
      1 package org.robolectric.fakes;
      2 
      3 import android.app.PendingIntent;
      4 import android.content.Context;
      5 import android.content.IIntentSender;
      6 import android.content.Intent;
      7 import android.content.IntentSender;
      8 import android.os.Handler;
      9 
     10 /**
     11  * Robolectric implementation of {@link android.content.IntentSender}.
     12  */
     13 public class RoboIntentSender extends IntentSender {
     14   public Intent intent;
     15   private PendingIntent pendingIntent;
     16 
     17   public RoboIntentSender(PendingIntent pendingIntent) {
     18     super((IIntentSender)null);
     19     this.pendingIntent = pendingIntent;
     20   }
     21 
     22   @Override public void sendIntent(Context context, int code, Intent intent,
     23                          final OnFinished onFinished, Handler handler, String requiredPermission)
     24       throws SendIntentException {
     25     try {
     26       pendingIntent.send(context, code, intent);
     27     } catch (PendingIntent.CanceledException e) {
     28       throw new SendIntentException(e);
     29     }
     30   }
     31 }
     32