In the application billing service, it is killed from time to time

Hi, we released this app on the market using inApp Billing, and our magazines show that BillingService (possibly the app itself) constantly takes killings on some client devices. Because of this, sometimes I can’t get a notification if the purchase was successful or not. Some customers often have to buy twice to make a successful purchase. Although this happens with a small percentage of customers, it is very alarming. Any idea why this might happen or what can be done to solve this problem.

+5
source share
2 answers

I'm not sure if this will help, but I would recommend making your preliminary BillingService service: http://developer.android.com/guide/components/services.html#Foreground

Here is a snippet of the documentation "API to put a service in the foreground state, where the system considers that this is what the user is actively aware of and therefore not a candidate for killing with low memory."

Perhaps a small percentage of your user has a low memory state and begins to kill services / applications (including yours).

+2
source

, ? , - 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();
        }
    };

};

, , , , .

, , . .

0

All Articles