5

嗨,我们通过 inApp Billing 在市场上发布了这个应用程序,我们的日志显示,BillingService(可能是应用程序本身)在某些客户设备上一直被随机杀死。因此,有时我无法收到购买成功与否的通知。一些客户经常需要购买两次才能成功购买。虽然这发生在一小部分客户身上,但它非常令人不安。知道为什么会发生这种情况,或者可以做些什么来解决这个问题。

4

2 回答 2

2

I am not sure whether it will help, but I would recommend to make your BillingService foreground service: http://developer.android.com/guide/components/services.html#Foreground

Here is piece of documentation "API to put the service in a foreground state, where the system considers it to be something the user is actively aware of and thus not a candidate for killing when low on memory. "

It could be that small percentage of your user has low memory condition and it's start killing services/applications (including yours).

于 2012-09-03T16:30:00.197 回答
0

您可以提供用于应用内计费的代码吗?可能是他们的设备不支持应用内计费,或者即使他们在尝试访问 Android Market 广播通知时失去了互联网连接。我在我的应用程序中使用的基本上是这样的:

@Override
public void onItemClick(AdapterView<?> arg0, View arg1, int arg2, long arg3) {
if( BillingHelper.isBillingSupported()){
        switch (arg2) {
        case 0:         
            Log.d("Appname", "30 coins");
            BillingHelper.requestPurchase(context, "com.paid.smallcoinbundle"); 
                 break;
        case 1: 
            Log.d("Appname", "85 coins");
            BillingHelper.requestPurchase(context, "com.paid.medcoinbundle"); 
                 break;
        case 2: 
            Log.d("Appname", "175 coins");
            BillingHelper.requestPurchase(context, "com.paid.midcoinbundle"); 
                 break;
        case 3:  
            Log.d("Appname", "500 coins");
            BillingHelper.requestPurchase(context, "com.paid.maxcoinbundle"); 
                 break;
        default: Log.d("Appname", "Something broke");
        break;
        }
    //  BillingHelper.requestPurchase(mContext, "android.test.purchased"); 
        // android.test.purchased or android.test.canceled or android.test.refunded or com.blundell.item.passport
    } else {
        LayoutInflater inflater = getLayoutInflater();
        View layout = inflater.inflate(R.layout.toast_layout,(ViewGroup) findViewById(R.id.toast_layout_root));
        TextView text = (TextView) layout.findViewById(R.id.text);
        text.setText("In App Billing isnt supported by your device");
        Toast toast = new Toast(getBaseContext());
        toast.setGravity(Gravity.CENTER_VERTICAL, 0, 0);
        toast.setDuration(Toast.LENGTH_LONG);
        toast.setView(layout);
        toast.show();
        return;
    }
}

然后 :

public Handler mTransactionHandler = new Handler(){
    public void handleMessage(android.os.Message msg) {
        Log.d("Appname", "Transaction complete");
        Log.d("Appname", "Transaction status: "+BillingHelper.latestPurchase.purchaseState);
        Log.d("Appname", "Item purchased is: "+BillingHelper.latestPurchase.productId);

        if(BillingHelper.latestPurchase.isPurchased()){
            Log.d("Appname", "Ispurchased : " + BillingHelper.latestPurchase.productId);
            if(BillingHelper.latestPurchase.productId.equals("com.paid.smallcoinbundle")){
                ConnectToServer.UpdateCoins(context,id,"add","30");
            }
            if(BillingHelper.latestPurchase.productId.equals("com.paid.medcoinbundle")){
                ConnectToServer.UpdateCoins(context,id,"add","85");
            }
            if(BillingHelper.latestPurchase.productId.equals("com..paid.midcoinbundle")){
                ConnectToServer.UpdateCoins(context,id,"add","175");
            }
            if(BillingHelper.latestPurchase.productId.equals("com.paid.maxcoinbundle")){
                ConnectToServer.UpdateCoins(context,id,"add","500");
            }

            finish();
        }
    };

};

既然您说应用内计费确实有效,尽管有时他们需要两次购买该物品,我假设您的包裹名称是正确的。

如果您要修复它以及问题所在,请告诉我。这是一个非常有趣的话题。

于 2012-08-30T00:26:30.537 回答