یک مشکل در خرید درون برنامه من تورو خدا کمک کنید
سلام این اکتیویت خرید منه میخای کد های ارتباط با بازار رو برام اضافه کنید کخگه برنتمم با لاکی هک نشه ممنون
import java.util.ArrayList;
import org.json.JSONException;
import android.app.*;
import android.graphics.Typeface;
import android.content.SharedPreferences.*;
import android.os.*;
import android.util.*;
import android.view.*;
import android.content.*;
import android.view.View.OnClickListener;
import android.widget.*;
import com.util.IabHelper.*;
import com.util.*;
import ir.dastankobdany13800.*;
import android.preference.*;
public class pro extends Activity {
protected static final int BUY_REQUEST_CODE = 12345;
private IabHelper buyHelper;
private Button butBuy;
public boolean premium;
//Getting the Price for the In-App SKU
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.pro);
butBuy = (Button) findViewById(R.id.button_buy);
//[...]
// Initially, disable the "buy me" button
butBuy.setEnabled(false);
buyHelper = new IabHelper(this,Billing. PUBLIC_KEY);
buyHelper.startSetup(new OnIabSetupFinishedListener() {
@Override
public void onIabSetupFinished(IabResult result) {
if(result.isSuccess()) {
// Fill a list of SKUs that we want the price infos for
// (SKU = "stockable unit" = buyable things)
ArrayList<String> moreSkus = new ArrayList<String>();
moreSkus.add(Billing.SKU_NAME_PREMIUM);
// We initialize the price field with a "retrieving price" message while we wait
// for the price
final TextView tvPrice = (TextView) findViewById(R.id.price);
tvPrice.setText("در حال انتظار جهت دریافت قیمت");
// Start the query for the details for the SKUs. This runs asynchronously, so
// it may be that the price appears a bit later after the rest of the Activity is shown.
buyHelper.queryInventoryAsync(true, moreSkus, new QueryInventoryFinishedListener() {
@Override
public void onQueryInventoryFinished(IabResult result, Inventory inv) {
if(result.isSuccess()) {
// If we successfully got the price, show it in the text field
SkuDetails details = inv.getSkuDetails(Billing.SKU_NAME_PREMIUM);
String price = details.getPrice();
tvPrice.setText(price);
// On successful init and price getting, enable the "buy me" button
butBuy.setEnabled(true);
} else {
// Error getting the price... show a sorry text in the price field now
tvPrice.setText("قیمت دریافت نشد");
//
butBuy.setEnabled(true);
//
}
}
});
}
}
});
//[...]
//Buying an In-App Item
//[...]
butBuy.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Disable the button after the click to prevent double clicks
butBuy.setEnabled(false);
// Start the purchase flow
buyHelper.launchPurchaseFlow(pro.this,
Billing.SKU_NAME_PREMIUM, BUY_REQUEST_CODE,
new OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase info) {
if (result.isSuccess()) {
// Successful - the item has been payed for
// We set a vale in the shared preferences to mark this app as
SharedPreferences shared = getSharedPreferences("Prefs", MODE_PRIVATE);
SharedPreferences.Editor editor = shared.edit();
editor.putBoolean(Billing.KEY_PREMIUM_VERSION, true);
editor.apply();
//
// The flag "CLEAR_TASK" is important, so the user is not sent
// back to this buy activity when he presses the back button.
//
Toast.makeText(getBaseContext(), "شما با موفقیت به نسخه کامل ارتقا یافتید",Toast.LENGTH_SHORT).show();
Intent intentz = new Intent(
pro.this,
MainActivity.class);
intentz.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK
| Intent.FLAG_ACTIVITY_NEW_TASK);
startActivity(intentz);
}
}
});
}
});
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
// Delegate the answer from the purchase request to the buying helper - necessary
// to let it handle the answers from the backend
buyHelper.handleActivityResult(requestCode, resultCode, data);
}
//Don’t forget to cleanup after
//ourselves when the BuyActivity ends:
@Override
protected void onDestroy() {
super.onDestroy();
buyHelper.dispose();
}
@Override
public void onBackPressed() {
backButtonHandler();
return;
}
public void backButtonHandler (){
AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(
pro.this);
// set title
alertDialogBuilder.setTitle("خروج");
// set dialog message
alertDialogBuilder
.setMessage("از خرید منصرف شدید؟")
.setIcon(R.drawable.ic_launcher)
.setCancelable(false)
.setPositiveButton("بله",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
// if this button is clicked, close
// current activity
System.exit(id);
}
})
.setNegativeButton("ادامه میدهم",
new DialogInterface.OnClickListener() {
public void onClick(DialogInterface dialog,
int id) {
dialog.cancel();
}
});
// create alert dialog
AlertDialog alertDialog = alertDialogBuilder.create();
// show it
alertDialog.show();
}
/*
@Override
public void onBackPressed() {
Intent ip=new Intent();
ip.setClass(BuyPremiumActivity.this,page3.class);
startActivity(ip);
Toast.makeText(getBaseContext(), "nemayeshe peyghame shoma",Toast.LENGTH_SHORT).show();
}
*/
}
پاسخگویی و مشاهده پاسخ های این سوال تنها برای اعضای ویژه سایت امکان پذیر است .
چنانچه تمایل دارید به همه بخش ها دسترسی داشته باشید میتوانید از این بخش لایسنس این آموزش را خریداری نمایید .