BillingService有Android的 - 无签名 [英] Billingservice Android - No signature

查看:114
本文介绍了BillingService有Android的 - 无签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我也跟着在下面的教程:<一href="http://blog.blundell-apps.com/simple-inapp-billing-payment/">http://blog.blundell-apps.com/simple-inapp-billing-payment/

我所做的一切的教程说,并再次读了所有的3倍以上,但还是我没有收到在<$在 intent.getStringExtra(INA​​PP_SIGNATURE)签名C $ C>的onReceive():BillingReceiver.java

这让我的应用程序崩溃,因为应用程序不能比较签名来验证,如果购买的是做正确。

这是我的BillingReceiver是这样的:

 公共类BillingReceiver扩展的BroadcastReceiver {

    私有静态最后字符串变量=BillingService有;

    @覆盖
    公共无效的onReceive(上下文的背景下,意图意图){
            串动= intent.getAction();
            Log.i(TAG,接收到的动作:+动作);
    如果(ACTION_PUR​​CHASE_STATE_CHANGED.equals(动作)){
        字符串的signedData = intent.getStringExtra(INA​​PP_SIGNED_DATA);
        特征码= intent.getStringExtra(INA​​PP_SIGNATURE);
        Log.e(TAG,&LT;  - 签名:+ intent.getExtras()的getString(inapp_signature));


        Log.i(TAG,&LT;  - 签名:+ intent.getStringExtra(INA​​PP_SIGNATURE));

        purchaseStateChanged(背景下,签名数据,签名);
    }否则如果(ACTION_NOTIFY.equals(动作)){
        字符串notifyId = intent.getStringExtra(NOTIFICATION_ID);
        通知(背景下,notifyId);
    }否则,如果(ACTION_RESPONSE_ code.equals(动作)){
        长的requestId = intent.getLongExtra(INA​​PP_REQUEST_ID,-1);
        INT响应codeINDEX = intent.getIntExtra(INA​​PP_RESPONSE_ code,C.Response code.RESULT_ERROR.ordinal());
        checkResponse code(背景下,将requestId,响应codeINDEX);
    } 其他 {
       Log.e(TAG,意想不到的动作:+动作);
    }
    }

    私人无效purchaseStateChanged(上下文的背景下,签名数据字符串,字符串签名){
            Log.i(TAG,purchaseStateChanged得到签名数据:+签名数据);
            Log.i(TAG,purchaseStateChanged得到了签名:+签名);
            BillingHelper.verifyPurchase(签名数据,签名);
    }

    私人无效通知(上下文的背景下,字符串notifyId){
            Log.i(TAG,通知了ID:+ notifyId);
            的String [] notifyIds = {notifyId};
            BillingHelper.getPurchaseInformation(notifyIds);
    }

    私人无效checkResponse code(上下文的背景下,长期的requestId,INT响应codeINDEX){
            Log.i(TAG,checkResponse code得到的requestId:+的requestId);
            Log.i(TAG,checkResponse code得到响应code:+ C.Response code.valueOf(响应codeINDEX));
    }
}
 

解决方案

是您的测试设备上的主账户与您的谷歌Play开发者帐户?

如果不是,你不会得到签名的android.test。*静电反应,除非该应用程序已发表在播放之前。

请参阅下表的<一个href="http://developer.android.com/guide/market/billing/billing_testing.html#static-responses-table">http://developer.android.com/guide/market/billing/billing_testing.html#static-responses-table为充分组条件

I have followed to following great tutorial at : http://blog.blundell-apps.com/simple-inapp-billing-payment/

I have done everything the tutorial says and have read everything 3 times over again but still i am not receiving a signature in the intent.getStringExtra(INAPP_SIGNATURE) in onReceive() : BillingReceiver.java

which makes my app crash because the app cant compare signatures to verify if the purchase is done correctly.

This is how my BillingReceiver looks like:

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));
    }
}

解决方案

Is the primary account on your test device the same as your Google Play developer account?

If not you won't get signatures on the android.test.* static responses unless the app has been published on Play before.

See the table at http://developer.android.com/guide/market/billing/billing_testing.html#static-responses-table for the full set of conditions.

这篇关于BillingService有Android的 - 无签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆