java – How can I get first signature using PackageInfo in API level 28?-ThrowExceptions

Exception or error:

I use the following codes to get the first signature from the package file:



    Signature[] signatures = context.getPackageManager()
       .getPackageInfo(context.getPackageName(),PackageManager.GET_SIGNATURES)
       .signatures;
    String firstSignature = signatures[0].toCharsString();


but I noticed that GET_SIGNATURES is deprecated in API level 28 and I have to use GET_SIGNING_CERTIFICATES instead.
So, how can I get the first signature in API level 28 and above?

How to solve:

Leave a Reply

Your email address will not be published. Required fields are marked *