public class

PendingIntentActivityWrapper

extends java.lang.Object

 java.lang.Object

↳androidx.core.service.quicksettings.PendingIntentActivityWrapper

Gradle dependencies

compile group: 'androidx.core', name: 'core', version: '1.15.0-alpha02'

  • groupId: androidx.core
  • artifactId: core
  • version: 1.15.0-alpha02

Artifact androidx.core:core:1.15.0-alpha02 it located at Google repository (https://maven.google.com/)

Androidx artifact mapping:

androidx.core:core com.android.support:support-compat

Overview

A wrapper class for developers to use with TileServiceCompat.startActivityAndCollapse(TileService, PendingIntentActivityWrapper).

Summary

Constructors
publicPendingIntentActivityWrapper(Context context, int requestCode, Intent intent, int flags, boolean isMutable)

publicPendingIntentActivityWrapper(Context context, int requestCode, Intent intent, int flags, Bundle options, boolean isMutable)

Methods
public ContextgetContext()

public intgetFlags()

public IntentgetIntent()

public BundlegetOptions()

public PendingIntentgetPendingIntent()

public intgetRequestCode()

public booleanisMutable()

from java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructors

public PendingIntentActivityWrapper(Context context, int requestCode, Intent intent, int flags, boolean isMutable)

public PendingIntentActivityWrapper(Context context, int requestCode, Intent intent, int flags, Bundle options, boolean isMutable)

Methods

public Context getContext()

public int getRequestCode()

public Intent getIntent()

public int getFlags()

public Bundle getOptions()

public boolean isMutable()

public PendingIntent getPendingIntent()

Source

/*
 * Copyright 2023 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package androidx.core.service.quicksettings;

import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.service.quicksettings.TileService;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.app.PendingIntentCompat;

/**
 * A wrapper class for developers to use with
 * {@link TileServiceCompat#startActivityAndCollapse(TileService, PendingIntentActivityWrapper)}.
 */
public class PendingIntentActivityWrapper {

    private final Context mContext;

    private final int mRequestCode;

    @NonNull
    private final Intent mIntent;

    @PendingIntentCompat.Flags
    private final int mFlags;

    @Nullable
    private final Bundle mOptions;

    @Nullable
    private final PendingIntent mPendingIntent;

    private final boolean mIsMutable;

    public PendingIntentActivityWrapper(@NonNull Context context, int requestCode,
            @NonNull Intent intent,
            @PendingIntentCompat.Flags int flags, boolean isMutable) {
        this(context, requestCode, intent, flags, null, isMutable);
    }

    public PendingIntentActivityWrapper(@NonNull Context context, int requestCode,
            @NonNull Intent intent,
            @PendingIntentCompat.Flags int flags, @Nullable Bundle options, boolean isMutable) {
        this.mContext = context;
        this.mRequestCode = requestCode;
        this.mIntent = intent;
        this.mFlags = flags;
        this.mOptions = options;
        this.mIsMutable = isMutable;

        mPendingIntent = createPendingIntent();
    }

    public @NonNull Context getContext() {
        return mContext;
    }

    public int getRequestCode() {
        return mRequestCode;
    }

    public @NonNull Intent getIntent() {
        return mIntent;
    }

    public int getFlags() {
        return mFlags;
    }

    public @NonNull Bundle getOptions() {
        return mOptions;
    }

    public boolean isMutable() {
        return mIsMutable;
    }

    public @Nullable PendingIntent getPendingIntent() {
        return mPendingIntent;
    }

    private @Nullable PendingIntent createPendingIntent() {
        if (mOptions == null) {
            return PendingIntentCompat.getActivity(mContext, mRequestCode, mIntent, mFlags,
                    mIsMutable);
        }
        return PendingIntentCompat.getActivity(mContext, mRequestCode, mIntent, mFlags, mOptions,
                mIsMutable);
    }
}