PackageIdentifier
Stay organized with collections
Save and categorize content based on your preferences.
This class represents a uniquely identifiable package.
Public Constructor Summary
Inherited Method Summary
From class java.lang.Object
Object
|
clone()
|
boolean |
|
void |
finalize()
|
final Class<?>
|
getClass()
|
int |
hashCode()
|
final void |
notify()
|
final void |
notifyAll()
|
String
|
toString()
|
final void |
wait(long arg0, int arg1)
|
final void |
wait(long arg0)
|
final void |
wait()
|
Public Constructors
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 |
Name of the package. |
sha256Certificate |
SHA-256 certificate digest of the package. |
Public Methods
public boolean equals (Object obj)
public String getPackageName ()
Returns the name for a package.
public byte[] getSha256Certificate ()
Returns the SHA-256 certificate for a package.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-10-31 UTC.
[null,null,["Last updated 2024-10-31 UTC."],[[["\u003cp\u003e\u003ccode\u003ePackageIdentifier\u003c/code\u003e uniquely identifies a package using its name and SHA-256 certificate digest.\u003c/p\u003e\n"],["\u003cp\u003eYou can create a \u003ccode\u003ePackageIdentifier\u003c/code\u003e using the package name and its SHA-256 certificate digest, obtainable via the \u003ccode\u003eapksigner\u003c/code\u003e tool.\u003c/p\u003e\n"],["\u003cp\u003eThis class provides methods to retrieve the package name (\u003ccode\u003egetPackageName\u003c/code\u003e) and SHA-256 certificate (\u003ccode\u003egetSha256Certificate\u003c/code\u003e).\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ePackageIdentifier\u003c/code\u003e includes standard methods like \u003ccode\u003eequals\u003c/code\u003e and \u003ccode\u003ehashCode\u003c/code\u003e for object comparison.\u003c/p\u003e\n"]]],["The `PackageIdentifier` class uniquely identifies a package using its name and SHA-256 certificate. Key actions include creating a `PackageIdentifier` instance with a package name and a byte array representing the SHA-256 certificate digest. Methods enable retrieving the package name and its SHA-256 certificate. Comparison of instances is done with `equals`, and `hashCode` is provided. The class can also utilize the method `apksigner verify --print-certs` to get the SHA-256 certificate.\n"],null,["# PackageIdentifier\n\npublic class **PackageIdentifier** extends [Object](//developer.android.com/reference/java/lang/Object.html) \nThis class represents a uniquely identifiable package. \n\n### Public Constructor Summary\n\n|---|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| | [PackageIdentifier](/android/reference/com/google/android/gms/appsearch/PackageIdentifier#PackageIdentifier(java.lang.String,%20byte[]))([String](//developer.android.com/reference/java/lang/String.html) packageName, byte\\[\\] sha256Certificate) Creates a unique identifier for a package. |\n\n### Public Method Summary\n\n|-------------------------------------------------------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| boolean | [equals](/android/reference/com/google/android/gms/appsearch/PackageIdentifier#equals(java.lang.Object))([Object](//developer.android.com/reference/java/lang/Object.html) obj) |\n| [String](//developer.android.com/reference/java/lang/String.html) | [getPackageName](/android/reference/com/google/android/gms/appsearch/PackageIdentifier#getPackageName())() Returns the name for a package. |\n| byte\\[\\] | [getSha256Certificate](/android/reference/com/google/android/gms/appsearch/PackageIdentifier#getSha256Certificate())() Returns the SHA-256 certificate for a package. |\n| int | [hashCode](/android/reference/com/google/android/gms/appsearch/PackageIdentifier#hashCode())() |\n\n### Inherited Method Summary\n\nFrom class java.lang.Object \n\n|----------------------------------------------------------------------------|--------------------------------------------------------------------------------|\n| [Object](//developer.android.com/reference/java/lang/Object.html) | clone() |\n| boolean | equals([Object](//developer.android.com/reference/java/lang/Object.html) arg0) |\n| void | finalize() |\n| final [Class](//developer.android.com/reference/java/lang/Class.html)\\\u003c?\\\u003e | getClass() |\n| int | hashCode() |\n| final void | notify() |\n| final void | notifyAll() |\n| [String](//developer.android.com/reference/java/lang/String.html) | toString() |\n| final void | wait(long arg0, int arg1) |\n| final void | wait(long arg0) |\n| final void | wait() |\n\nPublic Constructors\n-------------------\n\n#### public **PackageIdentifier** ([String](//developer.android.com/reference/java/lang/String.html) packageName, byte\\[\\] sha256Certificate)\n\nCreates a unique identifier for a package.\n\nSHA-256 certificate digests for a signed application can be retrieved with the\n[apksigner tool](/android/studio/command-line/apksigner) that is part of\nthe Android SDK build tools. Use `apksigner verify --print-certs\npath/to/apk.apk` to retrieve the SHA-256 certificate digest for the target\napplication. Once retrieved, the SHA-256 certificate digest should be converted to a\n`byte[]` by decoding it in base16: \n\n```\n new android.content.pm.Signature(outputDigest).toByteArray();\n \n``` \n\n##### Parameters\n\n| packageName | Name of the package. |\n| sha256Certificate | SHA-256 certificate digest of the package. |\n|-------------------|--------------------------------------------|\n\nPublic Methods\n--------------\n\n#### public boolean **equals** ([Object](//developer.android.com/reference/java/lang/Object.html) obj)\n\n#### public [String](//developer.android.com/reference/java/lang/String.html) **getPackageName** ()\n\nReturns the name for a package. \n\n#### public byte\\[\\] **getSha256Certificate** ()\n\nReturns the SHA-256 certificate for a package. \n\n#### public int **hashCode** ()"]]