sn0*_*0ep 5 android signature in-app-billing
我已经按照以下精彩教程进行了访问:http://blog.blundell-apps.com/simple-inapp-billing-payment/
我已经尽了一切的教程说,看了所有的3倍一遍又一遍,但我仍不能接受的签名intent.getStringExtra(INAPP_SIGNATURE)中onReceive() : BillingReceiver.java
这使我的应用程序崩溃,因为应用程序无法比较签名以验证购买是否正确完成.
这就是我的BillingReceiver的样子:
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));
}
}
Run Code Online (Sandbox Code Playgroud)
您的测试设备上的主要帐户是否与您的Google Play开发者帐户相同?
如果不是,你将不会在android.test.*静态响应上获得签名,除非该应用程序之前已在Play上发布.
有关完整的条件,请参阅http://developer.android.com/guide/market/billing/billing_testing.html#static-responses-table中的表格.
| 归档时间: |
|
| 查看次数: |
1605 次 |
| 最近记录: |