PDA

View Full Version : آموزش کامل فرار از دست Lucky Patcher



Pam.goudarzi
پنج شنبه 22 مرداد 1394, 12:27 عصر
دیدم خیلی از دوستان با پرداخت درون برنامه ای و قابلیت کرک شدنش با لاکی پچر مشکل دارن، گفتم یه کمکی کرده باشم :)
معمولا دوستان برای تنظیم حالت کاربر بعد از خرید درون برنامه ای از SharedPreferences استفاده می کنن که برنامه بفهمه که کاربر پرداخت درون برنامه ای رو انجام داده یا نه . که اگه این کارو کرده بود مثلا تو برنامه بزنه نسخه طلایی اگه نه نسخه معمولی.
معمولا هم از boolean یا int استفاده می کنن. روشی که به طور اتفاقی پیدا کردم که lucky patcher رو می شه باهاش دور زد هم ساده هست هم عملی. به طوری که لاکی پچر هیچ چیزی پیدا نمی کنه که بخواد اونو پچ کنه. (تست شده روی نسخه 5.6.8 لاکی پچر):

زمانی که کاربر خرید رو انجام داد، بجای استفاده از بولین یا عدد صحیح یک رشته داخل شیرد پریفرنسس بریزین:
buystatus = getSharedPreferences("buy_status", MODE_PRIVATE);


buystatus.edit().putString("premium", "premium").commit();



بعد داخل اکتیویتی های دیگه که خواستین وضعیت خرید کاربر رو ببینین از کد های زیر استفاده کنین:
buystatus = getSharedPreferences("buy_status", MODE_PRIVATE);
final String premium = buystatus.getString("premium", "nopremium");



if(premium.equals("premium")){

} else if(premium.equals("nopremium")){

}

در این صورت وقتی وارد Lucky Patcher میشین میزنه Nothing to patch
شاد باشید.

ehsanh22
پنج شنبه 22 مرداد 1394, 14:44 عصر
اگه میشه کد های کامل اکتیویتی پرداخت رو بدید ممنون میشم .
یه سوال : برای پرداخت های مصرفی چجوری باید جلوی لاکی رو گرفت ؟ مثلا حرید سکه . چون دیگه ما چک نمیکنیم

Pam.goudarzi
پنج شنبه 22 مرداد 1394, 15:24 عصر
public class BuyPremiumActivity extends Activity {


SharedPreferences buystatus;




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);


requestWindowFeature(Window.FEATURE_NO_TITLE);
setContentView(R.layout.buy_premium_activity);





butBuy = (Button) findViewById(R.id.button_buy);




Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/iransans.ttf");
butBuy.setTypeface(typeface);
TextView t1 = (TextView) findViewById(R.id.textView1);
TextView t3 = (TextView) findViewById(R.id.textView3);
TextView t4 = (TextView) findViewById(R.id.textView4);
TextView pricee = (TextView) findViewById(R.id.price);
pricee.setTypeface(typeface);

t1.setTypeface(typeface);
t3.setTypeface(typeface);
t4.setTypeface(typeface);



// [...]


// 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(BuyPremiumActivity.th is,
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.
//
//This is where all the Task is being done




buystatus = getSharedPreferences("buy_status", MODE_PRIVATE);
buystatus.edit().putString("premium", "premium").commit();

Log.d("PREMIUM_STATUS", "STATUS IS SET AS PREMIUM");

Toast.makeText(BuyPremiumActivity.this, "خرید با موفقیت انجام شد", Toast.LENGTH_SHORT).show();



startActivity(new Intent(BuyPremiumActivity.this, MainActivity.class));
finish();



















}

}
});
}
});
}


@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() {



startActivity(new Intent(BuyPremiumActivity.this, MainActivity.class));
finish();


Toast.makeText(BuyPremiumActivity.this, "خرید مختل شد" + ":(", Toast.LENGTH_SHORT).show();


}









}

Pam.goudarzi
پنج شنبه 22 مرداد 1394, 15:25 عصر
درباره ی محصول مصرفی اطلاعی ندارم چون کار نکردم.