# PackageIdentifier

Artifact: [androidx.appsearch:appsearch](https://developer.android.com/jetpack/androidx/releases/appsearch) [View Source](https://cs.android.com/search?q=file:androidx/appsearch/app/PackageIdentifier.java+class:androidx.appsearch.app.PackageIdentifier) Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

*** ** * ** ***

<br />

```
class PackageIdentifier
```

<br />

*** ** * ** ***

This class represents a uniquely identifiable package.

## Summary

| ### Public constructors |
|---|
| `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier#PackageIdentifier(java.lang.String,byte[])( packageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html, sha256Certificate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html> )` Creates a unique identifier for a package. |

| ### Public functions |
|---|---|
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-boolean/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier#equals(java.lang.Object)(obj: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-any/index.html?)` |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier#getPackageName()()` Returns the name for a package. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier#getSha256Certificate()()` Returns the SHA-256 certificate for a package. |
| `https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-int/index.html` | `https://developer.android.com/reference/kotlin/androidx/appsearch/app/PackageIdentifier#hashCode()()` |

## Public constructors

### PackageIdentifier

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
PackageIdentifier(
    packageName: String,
    sha256Certificate: ByteArray<Byte>
)
```

Creates a unique identifier for a package.

SHA-256 certificate digests for a signed application can be retrieved with the [apksigner tool](https://developer.android.com/studio/command-line/apksigner) that is part of the Android SDK build tools. Use `apksigner verify --print-certs path/to/apk.apk` to retrieve the SHA-256 certificate digest for the target application. Once retrieved, the SHA-256 certificate digest should be converted to a `byte[]` by decoding it in base16:

```kotlin
new android.content.pm.Signature(outputDigest).toByteArray();
```

| Parameters |
|---|---|
| `packageName: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-string/index.html` | Name of the package. |
| `sha256Certificate: https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte-array/index.html<https://kotlinlang.org/api/core/kotlin-stdlib/kotlin/-byte/index.html>` | SHA-256 certificate digest of the package. |

## Public functions

### equals

```
fun equals(obj: Any?): Boolean
```

### getPackageName

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getPackageName(): String
```

Returns the name for a package.

### getSha256Certificate

Added in [1.1.0](https://developer.android.com/jetpack/androidx/releases/appsearch#1.1.0)

```
fun getSha256Certificate(): Array<Byte>
```

Returns the SHA-256 certificate for a package.

### hashCode

```
fun hashCode(): Int
```