public final class

QRCodeSignInMethod

extends java.lang.Object

implements SignInTemplate.SignInMethod

 java.lang.Object

↳androidx.car.app.model.signin.QRCodeSignInMethod

Gradle dependencies

compile group: 'androidx.car.app', name: 'app', version: '1.2.0-rc01'

  • groupId: androidx.car.app
  • artifactId: app
  • version: 1.2.0-rc01

Artifact androidx.car.app:app:1.2.0-rc01 it located at Google repository (https://maven.google.com/)

Overview

A SignInTemplate.SignInMethod that presents a QR Code that the user can use to sign-in.

Summary

Constructors
publicQRCodeSignInMethod(Uri uri)

Returns a QRCodeSignInMethod instance.

Methods
public booleanequals(java.lang.Object other)

public UrigetUri()

Returns the to use to create a QR Code to present to the user.

public inthashCode()

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

Constructors

public QRCodeSignInMethod(Uri uri)

Returns a QRCodeSignInMethod instance.

Parameters:

uri: the URL to be used in creating a QR Code.

Methods

public Uri getUri()

Returns the to use to create a QR Code to present to the user.

public boolean equals(java.lang.Object other)

public int hashCode()

Source

/*
 * Copyright 2021 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.car.app.model.signin;

import static java.util.Objects.requireNonNull;

import android.net.Uri;

import androidx.annotation.Keep;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.car.app.annotations.RequiresCarApi;

import java.util.Objects;

/**
 * A {@link SignInTemplate.SignInMethod} that presents a QR Code that the user can use to sign-in.
 */
@RequiresCarApi(4)
@SuppressWarnings("AcronymName")
public final class QRCodeSignInMethod implements SignInTemplate.SignInMethod {
    @Keep
    @Nullable
    private final Uri mUri;

    /**
     * Returns a {@link QRCodeSignInMethod} instance.
     *
     * @param uri the URL to be used in creating a QR Code.
     * @throws NullPointerException     if {@code url} is {@code null}
     */
    public QRCodeSignInMethod(@NonNull Uri uri) {
        mUri = requireNonNull(uri);
    }

    /** Returns the {@link Uri} to use to create a QR Code to present to the user. */
    @NonNull
    public Uri getUri() {
        return requireNonNull(mUri);
    }

    @Override
    public boolean equals(Object other) {
        if (this == other) {
            return true;
        }

        if (!(other instanceof QRCodeSignInMethod)) {
            return false;
        }

        QRCodeSignInMethod that = (QRCodeSignInMethod) other;
        return Objects.equals(mUri, that.mUri);
    }

    @Override
    public int hashCode() {
        return Objects.hash(mUri);
    }

    /** Constructs an empty instance, used by serialization code. */
    private QRCodeSignInMethod() {
        mUri = null;
    }
}