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