这是我正在使用的代码。我已在适当的位置替换了原始 API 密钥。我在Google Play应用内控制台中更改了示例标题和描述,还替换了公钥,但代替标题和描述,它显示的是应用程序的默认标题,而不是我在应用内控制台中使用的标题.
我附上了屏幕截图以便更好地理解。我正在测试已经上传到 Google Play的签名APK 。问题是什么?
该应用程序正在成功运行。
代码
public static ArrayList<VerifiedPurchase> verifyPurchase(String signedData, String signature) {
if (signedData == null) {
Log.e(TAG, "data is null");
return null;
}
Log.i(TAG, "signedData: " + signedData);
boolean verified = false;
if (!TextUtils.isEmpty(signature)) {
/**
* Compute your public key (that you got from the Android Market
* publisher site).
*
* Instead of just storing the entire literal string here embedded
* in the program, construct the key at runtime from pieces or use
* bit manipulation (for example, XOR with some other string) to
* hide the actual key. The key itself is not secret information,
* but we don't want to make it easy for an adversary to replace the
* public key with one of their own and then fake messages from the
* server.
*
* Generally, encryption keys / passwords should only be kept in
* memory long enough to perform the operation they need to perform.
*/
String base64EncodedPublicKey = "<MY API KEY>";
PublicKey key = BillingSecurity.generatePublicKey(base64EncodedPublicKey);
verified = BillingSecurity.verify(key, signedData, signature);
if (!verified) {
Log.w(TAG, "signature does not match data.");
return null;
}
}