PackageIdentifier

public class PackageIdentifier
extends Object

java.lang.Object
   ↳ androidx.appsearch.app.PackageIdentifier


This class represents a uniquely identifiable package.

Summary

Public constructors

PackageIdentifier(String packageName, byte[] sha256Certificate)

Creates a unique identifier for a package.

Public methods

boolean equals(Object obj)
String getPackageName()
byte[] getSha256Certificate()
int hashCode()

Inherited methods

Public constructors

PackageIdentifier

public PackageIdentifier (String packageName, 
                byte[] sha256Certificate)

Creates a unique identifier for a package.

SHA-256 certificate digests for a signed application can be retrieved with the apksigner tool 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:

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

Parameters
packageName String: Name of the package.

sha256Certificate byte: SHA-256 certificate digest of the package.

Public methods

equals

public boolean equals (Object obj)

Parameters
obj Object

Returns
boolean

getPackageName

public String getPackageName ()

Returns
String

getSha256Certificate

public byte[] getSha256Certificate ()

Returns
byte[]

hashCode

public int hashCode ()

Returns
int