Search in sources :

Example 76 with IntentSender

use of android.content.IntentSender in project android_packages_apps_Settings by crdroidandroid.

the class ChooseLockSettingsHelper method copyOptionalExtras.

private void copyOptionalExtras(Intent inIntent, Intent outIntent) {
    IntentSender intentSender = inIntent.getParcelableExtra(Intent.EXTRA_INTENT);
    if (intentSender != null) {
        outIntent.putExtra(Intent.EXTRA_INTENT, intentSender);
    }
    int taskId = inIntent.getIntExtra(Intent.EXTRA_TASK_ID, -1);
    if (taskId != -1) {
        outIntent.putExtra(Intent.EXTRA_TASK_ID, taskId);
    }
    // TODO: Remove once that bug is fixed.
    if (intentSender != null || taskId != -1) {
        outIntent.addFlags(Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
        outIntent.addFlags(Intent.FLAG_ACTIVITY_NO_HISTORY);
    }
}
Also used : IntentSender(android.content.IntentSender)

Example 77 with IntentSender

use of android.content.IntentSender in project android_packages_apps_Settings by crdroidandroid.

the class NotificationStation method formatPendingIntent.

private static String formatPendingIntent(PendingIntent pi) {
    final StringBuilder sb = new StringBuilder();
    final IntentSender is = pi.getIntentSender();
    sb.append("Intent(pkg=").append(is.getCreatorPackage());
    try {
        final boolean isActivity = ActivityManager.getService().isIntentSenderAnActivity(is.getTarget());
        if (isActivity)
            sb.append(" (activity)");
    } catch (RemoteException ex) {
    }
    sb.append(")");
    return sb.toString();
}
Also used : SpannableStringBuilder(android.text.SpannableStringBuilder) IntentSender(android.content.IntentSender) RemoteException(android.os.RemoteException)

Example 78 with IntentSender

use of android.content.IntentSender in project KeePassDX by Kunzisoft.

the class KeeAutofillService method onFillRequest.

@Override
public void onFillRequest(@NonNull FillRequest request, @NonNull CancellationSignal cancellationSignal, @NonNull FillCallback callback) {
    List<FillContext> fillContexts = request.getFillContexts();
    AssistStructure latestStructure = fillContexts.get(fillContexts.size() - 1).getStructure();
    cancellationSignal.setOnCancelListener(() -> Log.e(TAG, "Cancel autofill not implemented in this sample."));
    FillResponse.Builder responseBuilder = new FillResponse.Builder();
    // Check user's settings for authenticating Responses and Datasets.
    StructureParser.Result parseResult = new StructureParser(latestStructure).parse();
    AutofillId[] autofillIds = parseResult.allAutofillIds();
    if (!Arrays.asList(autofillIds).isEmpty()) {
        // If the entire Autofill Response is authenticated, AuthActivity is used
        // to generate Response.
        IntentSender sender = AutoFillAuthActivity.getAuthIntentSenderForResponse(this);
        RemoteViews presentation = new RemoteViews(getPackageName(), R.layout.autofill_service_unlock);
        responseBuilder.setAuthentication(autofillIds, sender, presentation);
        callback.onSuccess(responseBuilder.build());
    }
}
Also used : RemoteViews(android.widget.RemoteViews) FillResponse(android.service.autofill.FillResponse) FillContext(android.service.autofill.FillContext) AssistStructure(android.app.assist.AssistStructure) AutofillId(android.view.autofill.AutofillId) IntentSender(android.content.IntentSender)

Example 79 with IntentSender

use of android.content.IntentSender in project robolectric by robolectric.

the class ShadowActivityTest method getLastIntentSenderRequest.

@Test
public void getLastIntentSenderRequest() throws IntentSender.SendIntentException {
    Activity activity = Robolectric.setupActivity(Activity.class);
    int requestCode = 108;
    Intent intent = new Intent("action");
    Intent fillInIntent = new Intent();
    PendingIntent pendingIntent = PendingIntent.getActivity(systemContext, requestCode, intent, 0);
    Bundle options = new Bundle();
    int flagsMask = 1;
    int flagsValues = 2;
    int extraFlags = 3;
    IntentSender intentSender = pendingIntent.getIntentSender();
    activity.startIntentSenderForResult(intentSender, requestCode, fillInIntent, flagsMask, flagsValues, extraFlags, options);
    IntentSenderRequest lastIntentSenderRequest = shadowOf(activity).getLastIntentSenderRequest();
    assertThat(lastIntentSenderRequest.intentSender).isEqualTo(intentSender);
    assertThat(lastIntentSenderRequest.fillInIntent).isEqualTo(fillInIntent);
    assertThat(lastIntentSenderRequest.requestCode).isEqualTo(requestCode);
    assertThat(lastIntentSenderRequest.flagsMask).isEqualTo(flagsMask);
    assertThat(lastIntentSenderRequest.flagsValues).isEqualTo(flagsValues);
    assertThat(lastIntentSenderRequest.extraFlags).isEqualTo(extraFlags);
    assertThat(lastIntentSenderRequest.options).isEqualTo(options);
}
Also used : Bundle(android.os.Bundle) Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IntentSenderRequest(org.robolectric.shadows.ShadowActivity.IntentSenderRequest) PendingIntent(android.app.PendingIntent) IntentSender(android.content.IntentSender) Test(org.junit.Test)

Example 80 with IntentSender

use of android.content.IntentSender in project robolectric by robolectric.

the class ShadowActivityTest method startIntentSenderForResult_throwsException.

@Test
public void startIntentSenderForResult_throwsException() {
    Activity activity = Robolectric.setupActivity(Activity.class);
    shadowOf(activity).setThrowIntentSenderException(true);
    IntentSender intentSender = PendingIntent.getActivity(systemContext, 0, new Intent("action"), 0).getIntentSender();
    try {
        activity.startIntentSenderForResult(intentSender, 0, null, 0, 0, 0);
        fail("An IntentSender.SendIntentException should have been thrown");
    } catch (IntentSender.SendIntentException e) {
    // NOP
    }
}
Also used : Robolectric.setupActivity(org.robolectric.Robolectric.setupActivity) Robolectric.buildActivity(org.robolectric.Robolectric.buildActivity) Activity(android.app.Activity) PendingIntent(android.app.PendingIntent) Intent(android.content.Intent) IntentSender(android.content.IntentSender) Test(org.junit.Test)

Aggregations

IntentSender (android.content.IntentSender)94 Intent (android.content.Intent)48 IIntentSender (android.content.IIntentSender)46 PendingIntent (android.app.PendingIntent)40 RemoteException (android.os.RemoteException)30 UserHandle (android.os.UserHandle)14 ActivityOptions (android.app.ActivityOptions)13 KeyguardManager (android.app.KeyguardManager)10 UserInfo (android.content.pm.UserInfo)10 Bundle (android.os.Bundle)10 IActivityManager (android.app.IActivityManager)8 ComponentName (android.content.ComponentName)8 ActivityInfo (android.content.pm.ActivityInfo)8 ResolveInfo (android.content.pm.ResolveInfo)8 HeavyWeightSwitcherActivity (com.android.internal.app.HeavyWeightSwitcherActivity)8 AccountManager (android.accounts.AccountManager)7 Activity (android.app.Activity)7 PackageManager (android.content.pm.PackageManager)7 Point (android.graphics.Point)7 SpannableStringBuilder (android.text.SpannableStringBuilder)7