Billingservice Android-无签名
我在以下网站上学习了以下精彩教程: 我已经完成了教程中所说的所有内容,并且已经将所有内容重新阅读了3遍,但是我仍然没有在Billingservice Android-无签名,android,signature,in-app-billing,Android,Signature,In App Billing,我在以下网站上学习了以下精彩教程: 我已经完成了教程中所说的所有内容,并且已经将所有内容重新阅读了3遍,但是我仍然没有在intent.getStringExtra(INAPP\u签名)中的onReceive():BillingReceiver.java 这使得我的应用程序崩溃,因为应用程序无法比较签名来验证购买是否正确 这就是我的计费接收器的外观: public class BillingReceiver extends BroadcastReceiver { private stat
intent.getStringExtra(INAPP\u签名)
中的onReceive():BillingReceiver.java
这使得我的应用程序崩溃,因为应用程序无法比较签名来验证购买是否正确
这就是我的计费接收器的外观:
public class BillingReceiver extends BroadcastReceiver {
private static final String TAG = "BillingService";
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i(TAG, "Received action: " + action);
if (ACTION_PURCHASE_STATE_CHANGED.equals(action)) {
String signedData = intent.getStringExtra(INAPP_SIGNED_DATA);
String signature = intent.getStringExtra(INAPP_SIGNATURE);
Log.e(TAG, "<!-- SIGNATURE : "+ intent.getExtras().getString("inapp_signature"));
Log.i(TAG, "<!-- SIGNATURE : "+intent.getStringExtra(INAPP_SIGNATURE));
purchaseStateChanged(context, signedData, signature);
} else if (ACTION_NOTIFY.equals(action)) {
String notifyId = intent.getStringExtra(NOTIFICATION_ID);
notify(context, notifyId);
} else if (ACTION_RESPONSE_CODE.equals(action)) {
long requestId = intent.getLongExtra(INAPP_REQUEST_ID, -1);
int responseCodeIndex = intent.getIntExtra(INAPP_RESPONSE_CODE, C.ResponseCode.RESULT_ERROR.ordinal());
checkResponseCode(context, requestId, responseCodeIndex);
} else {
Log.e(TAG, "unexpected action: " + action);
}
}
private void purchaseStateChanged(Context context, String signedData, String signature) {
Log.i(TAG, "purchaseStateChanged got signedData: " + signedData);
Log.i(TAG, "purchaseStateChanged got signature: " + signature);
BillingHelper.verifyPurchase(signedData, signature);
}
private void notify(Context context, String notifyId) {
Log.i(TAG, "notify got id: " + notifyId);
String[] notifyIds = {notifyId};
BillingHelper.getPurchaseInformation(notifyIds);
}
private void checkResponseCode(Context context, long requestId, int responseCodeIndex) {
Log.i(TAG, "checkResponseCode got requestId: " + requestId);
Log.i(TAG, "checkResponseCode got responseCode: " + C.ResponseCode.valueOf(responseCodeIndex));
}
}
公共类BillingReceiver扩展了BroadcastReceiver{
私有静态最终字符串标记=“BillingService”;
@凌驾
公共void onReceive(上下文、意图){
String action=intent.getAction();
Log.i(标签,“接收到的操作:”+操作);
如果(行动\购买\状态\改变,等于(行动)){
String signedData=intent.getStringExtra(INAPP\u SIGNED\u数据);
字符串签名=intent.getStringExtra(INAPP_签名);
Log.e(TAG,“测试设备上的主帐户与Google Play开发者帐户相同吗
如果没有,你将无法在android.test.*上获得签名。静态响应,除非该应用之前已发布在Play上
完整的条件见表。我也面临同样的问题。感谢您的帮助。我认为该表不太合适。我应该在该表的第6行(已发布的应用程序(尽管未发布计费)、已上传计费的apk草案、设备上的非开发帐户),但我得到了一个空的sig。更改为开发设备,一切正常。也许第一列指的是已经包含计费的应用程序的发布版本。@William我尝试使用应用内计费版本3 api。尝试使用开发人员的手机购买保留的产品id(静态).购买成功,但签名为空。有什么想法吗?@Krishnabhadra我认为静态ID不再返回签名。请看@TalkLittle hmm。我发现这很难。现在获得签名的唯一方法是使用测试帐户进行真正的购买。谷歌非常非常差。整个应用内计费测试系统都是垃圾。yjo您可能希望使用此信息更新答案。。