在App Billing服务有时会被杀死

the*_*abh 5 service android termination in-app-billing

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

Ush*_*doo 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;
    }
}
Run Code Online (Sandbox Code Playgroud)

然后 :

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();
        }
    };
Run Code Online (Sandbox Code Playgroud)

};

既然您说应用程序内计费确实有效,尽管有时他们需要购买该商品两次,我认为您的软件包名称是正确的。

请告诉我您是否要修复它以及问题是什么。这是一个非常有趣的话题。