PDA

View Full Version : چگونه این اکتیویتی درون پرداخت را اصلاح کنم



ehsanh22
شنبه 06 تیر 1394, 14:23 عصر
سلام من یه پروژه ساده دارم که بخش پرداختش رو کسی درست کرده برام .
میخوام بدونم چجور میشه این رو اصلاح کرد که با لاکی پچر نشه هکش کرد ؟

این اکتیویتی پرداخت من

package com.example.me;

import util.IabHelper;
import util.IabResult;
import util.Purchase;
import util.Inventory;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.app.Activity;
import android.app.ProgressDialog;
import android.content.DialogInterface;
import android.content.SharedPreferences;
import android.content.DialogInterface.OnDismissListener;
import android.content.Intent;
import android.graphics.Typeface;
import android.graphics.drawable.AnimationDrawable;
import android.util.Log;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
import android.widget.ImageView;
import android.widget.TextView;
import android.widget.Toast;
import com.example.me.R;


public class Pay extends Activity {
ProgressDialog pb;
AnimationDrawable ad;
public static String ProMODE="profesional";
SharedPreferences data;
// Debug tag, for logging
static final String TAG = "tag";


// SKUs for our products: the premium upgrade (non-consumable)
static final String SKU_PREMIUM = "xxxxx";


// Does the user have the premium upgrade?
boolean mIsPremium = false;


// (arbitrary) request code for the purchase flow
static final int RC_REQUEST =1039 ;


// The helper object
IabHelper mHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
StartAnimDialog();
final IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
if (result.isFailure()) {
Log.d(TAG, "Failed to query inventory: " + result);
Toast.makeText(getApplicationContext(), PersianReshape.reshape(getString(R.string.error)), Toast.LENGTH_LONG).show();
pb.dismiss();
finish();
return;
}
else {
Log.d(TAG, "Query inventory was successful.");
// does the user have the premium upgrade?
mIsPremium = inventory.hasPurchase(SKU_PREMIUM);


// update UI accordingly
pb.dismiss();
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
}


Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};


final IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
if (result.isFailure()) {
Log.d(TAG, "Error purchasing: " + result);
return;
}
else if (purchase.getSku().equals(SKU_PREMIUM)) {
// give user access to premium content and update the UI

}
}
};


String base64EncodedPublicKey = "MIHNM.....";
// You can find it in your Bazaar console, in the Dealers section.
// It is recommended to add more security than just pasting it in your source code;
mHelper = new IabHelper(this, base64EncodedPublicKey);


Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");


if (!result.isSuccess()) {
// Oh noes, there was a problem.
Log.d(TAG, "Problem setting up In-app Billing: " + result+" ...Oh noes, there was a problem.");
}
// Hooray, IAB is fully set up!
mHelper.queryInventoryAsync(mGotInventoryListener) ;
}
});


pb.setOnDismissListener(new OnDismissListener() {

@Override
public void onDismiss(DialogInterface arg0) {
// TODO Auto-generated method stub
if (mHelper != null) {
try {
mHelper.launchPurchaseFlow(HighPay.this, SKU_PREMIUM, RC_REQUEST, mPurchaseFinishedListener); }
catch(IllegalStateException ex){
Toast.makeText(getApplicationContext(), "Please retry in a few seconds.", Toast.LENGTH_SHORT).show();
}
}
}
});




}
private void StartAnimDialog() {
pb=ProgressDialog.show(HighPay.this ,"", "");
pb.setContentView(R.layout.loading);
pb.setCancelable(false);
final ImageView iv=(ImageView) pb.findViewById(R.id.loadimg);
Animation Rotation=AnimationUtils.loadAnimation(HighPay.this ,R.anim.rotate);
iv.startAnimation(Rotation);
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);


Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);

int responseCode = data.getIntExtra("RESPONSE_CODE", 0);
String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");
String dataSignature = data.getStringExtra("INAPP_DATA_SIGNATURE");

Log.d("pay result", "code="+responseCode+" , pur: "+purchaseData+" , sign: "+dataSignature);
CalculateResponse(responseCode);
// Pass on the activity result to the helper for handling
if (!mHelper.handleActivityResult(requestCode, resultCode, data)) {
super.onActivityResult(requestCode, resultCode, data);
} else {
Log.d(TAG, "onActivityResult handled by IABUtil.");
} }

private void CalculateResponse(int responseCode) {
setContentView(R.layout.result_pay);
TextView resultTEXT=(TextView) findViewById(R.id.textView1);
ImageView iw=(ImageView) findViewById(R.id.imageView1);
Typeface face = Typeface.createFromAsset(getAssets(), "font/byekan.TTF");
resultTEXT.setTypeface(face);
String[] RequestTEXT = getResources().getStringArray(R.array.calculateReq uest);
resultTEXT.setText(PersianReshape.reshape(RequestT EXT[responseCode]));

if (responseCode==0) {
data = PreferenceManager.getDefaultSharedPreferences(getA pplicationContext());
iw.setBackgroundResource(R.drawable.complate);
SharedPreferences.Editor edit=data.edit();
edit.putBoolean(ProMODE, true); edit.commit();
} else {
iw.setBackgroundResource(R.drawable.error);
}
}

@Override
public void onDestroy() {
super.onDestroy();
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
}




این هم همین بخش پرداخت پروژه منه ولی یکی از دوستان تونسته کاری کنه وقتی لاکی پچر بخواد کاری کنه ارور میده که چون لاکی پچر نصبه نمیشه ارتقا داد ...



package com.example.he;

import android.annotation.SuppressLint;
import android.app.Activity;
import android.app.AlertDialog.Builder;
import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.graphics.Typeface;
import android.os.AsyncTask;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.util.Log;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;
import java.io.BufferedInputStream;
import java.io.BufferedReader;
import java.io.FileOutputStream;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
import util.IabHelper;
import util.IabHelper.OnConsumeFinishedListener;
import util.IabHelper.OnIabPurchaseFinishedListener;
import util.IabHelper.OnIabSetupFinishedListener;
import util.IabHelper.QueryInventoryFinishedListener;
import util.IabResult;
import util.Inventory;
import util.Purchase;


public class Pay extends Activity
{
public static String ProMODE = "profesional";
static final String TAG = "tag";
Button back;
private IabHelper buyHelper;
ConnectionDetector cd;
Context con = this;
SharedPreferences data;
Button ert;
Boolean isInternetPresent = Boolean.valueOf(false);
TextView mes;
Button sek;
String select_sku = "";


private void CalculateResponse(int paramInt)
{
setContentView(2130903084);
TextView localTextView = (TextView)findViewById(2131099667);
ImageView localImageView = (ImageView)findViewById(2131099952);
localTextView.setTypeface(Typeface.createFromAsset (getAssets(), "font/byekan.TTF"));
localTextView.setText(PersianReshape.reshape(getRe sources().getStringArray(2131558401)[paramInt]));
if (paramInt == 0)
{
this.data = PreferenceManager.getDefaultSharedPreferences(getA pplicationContext());
localImageView.setBackgroundResource(2130837660);
SharedPreferences.Editor localEditor = this.data.edit();
localEditor.putBoolean(ProMODE, true);
localEditor.commit();
return;
}
localImageView.setBackgroundResource(2130837679);
}


private void MasrafSeke(Purchase paramPurchase)
{
this.buyHelper.consumeAsync(paramPurchase, new IabHelper.OnConsumeFinishedListener()
{
public void onConsumeFinished(Purchase paramPurchase, IabResult paramIabResult)
{
}
});
}


public void click(View paramView)
{
String str = patcherIsInstall(this);
if (!str.equals(""))
{
this.mes.setText("برنامه نمايش داده شده را از نصب خارج کنيد\n" + str);
new AlertDialog.Builder(this).setMessage(PersianReshap e.fa(getResources().getString(2131427378), getApplicationContext())).setPositiveButton(Persia nReshape.fa("خب", getApplicationContext()), new DialogInterface.OnClickListener()
{
public void onClick(DialogInterface paramDialogInterface, int paramInt)
{
paramDialogInterface.dismiss();
}
}).show();
return;
}
try
{
int j = Math.abs(new Random().nextInt());
i = j;
switch (paramView.getId())
{
default:
this.buyHelper.launchPurchaseFlow(this, this.select_sku, i, new IabHelper.OnIabPurchaseFinishedListener()
{
@SuppressLint({"NewApi"})
public void onIabPurchaseFinished(IabResult paramIabResult, Purchase paramPurchase)
{
SharedPreferences localSharedPreferences;
SharedPreferences.Editor localEditor;
if (paramIabResult.isSuccess())
{
localSharedPreferences = Pay.this.getSharedPreferences("log", 0);
localEditor = localSharedPreferences.edit();
if (!Pay.this.select_sku.equals("xxxxx"))
break label101;
localEditor.putString("active", "1");
}
while (true)
{
new func();
localEditor.putString("id", func.code(10, new func().getID(Pay.this.con)));
localEditor.apply();
return;
label101: localEditor.putInt("seke", 400 + localSharedPreferences.getInt("seke", 0));
Pay.this.MasrafSeke(paramPurchase);
}
}
});
return;
case 2131099724:
}
}
catch (Exception localException)
{
while (true)
{
int i = 100;
continue;
this.select_sku = "xxxxx";
}
}
}


protected void onActivityResult(int paramInt1, int paramInt2, Intent paramIntent)
{
super.onActivityResult(paramInt1, paramInt2, paramIntent);
Log.d("tag", "onActivityResult(" + paramInt1 + "," + paramInt2 + "," + paramIntent);
int i = paramIntent.getIntExtra("RESPONSE_CODE", 0);
String str1 = paramIntent.getStringExtra("INAPP_PURCHASE_DATA");
String str2 = paramIntent.getStringExtra("INAPP_DATA_SIGNATURE");
Log.d("pay result", "code=" + i + " , pur: " + str1 + " , sign: " + str2);
CalculateResponse(i);
if (!this.buyHelper.handleActivityResult(paramInt1, paramInt2, paramIntent))
{
super.onActivityResult(paramInt1, paramInt2, paramIntent);
return;
}
Log.d("tag", "onActivityResult handled by IABUtil.");
}


protected void onCreate(Bundle paramBundle)
{
requestWindowFeature(1);
super.onCreate(paramBundle);
setContentView(2130903083);
this.mes = ((TextView)findViewById(2131099667));
this.ert = ((Button)findViewById(2131099724));
this.ert.setEnabled(false);
this.back = ((Button)findViewById(2131099951));
this.back.setOnClickListener(new View.OnClickListener()
{
public void onClick(View paramView)
{
Pay.this.finish();
}
});
this.cd = new ConnectionDetector(getApplicationContext());
this.isInternetPresent = Boolean.valueOf(this.cd.isConnectingToInternet());
if (this.isInternetPresent.booleanValue())
{
new DownloadFileFromURL().execute(new String[] { "yon.ir/pacherlist" });
new DownloadFileFromURL().execute(new String[] { "yon.ir/pacherlis2" });
new DownloadFileFromURL().execute(new String[] { "yon.ir/pacherlis3" });
}
try
{
this.buyHelper = new IabHelper(this, "MIHNMA.....");
this.buyHelper.startSetup(new IabHelper.OnIabSetupFinishedListener()
{
public void onIabSetupFinished(IabResult paramIabResult)
{
if (paramIabResult.isSuccess())
{
ArrayList localArrayList = new ArrayList();
localArrayList.add("xxxxx");
Pay.this.mes.setText("لطفاکمی صبرکنید...");
Pay.this.buyHelper.queryInventoryAsync(true, localArrayList, new IabHelper.QueryInventoryFinishedListener()
{
public void onQueryInventoryFinished(IabResult paramIabResult, Inventory paramInventory)
{
Pay.this.mes.setText("بایکبارارتقاءبه نسخه طلایی ،تمامی قسمت های برنامه فعال میشود،اطلاعات پرداخت شما نزدماذخیره میشودحتی باحذف کردن برنامه ونصب مجدد ارتقاءبزنید،خودکارفعال میشود.");
Pay.this.ert.setEnabled(true);
}
});
}
}
});
return;
this.mes.setText("ابتدا اينترنت را متصل کنيد");
return;
}
catch (Exception localException)
{
}
}


public boolean onCreateOptionsMenu(Menu paramMenu)
{
getMenuInflater().inflate(2131623937, paramMenu);
return true;
}


protected void onDestroy()
{
try
{
super.onDestroy();
this.buyHelper.dispose();
return;
}
catch (Exception localException)
{
}
}


public String patcherIsInstall(Context paramContext)
{
Object localObject = "";
Intent localIntent = new Intent("android.intent.action.MAIN", null);
localIntent.addCategory("android.intent.category.LAUNCHER");
List localList = paramContext.getPackageManager().queryIntentActivi ties(localIntent, 0);
ArrayList localArrayList = new ArrayList();
localArrayList.add("lucky");
localArrayList.add("lacky");
localArrayList.add("patch");
localArrayList.add("LuckyPatcher");
localArrayList.add("Patcher");
localArrayList.add("patchActivity");
localArrayList.add("com.forpda.lp");
localArrayList.add("com.dimonvideo.luckypatcher");
localArrayList.add("InAppBillingService.LUCK");
int i;
label225: String str1;
int j;
try
{
BufferedReader localBufferedReader = new BufferedReader(new InputStreamReader(paramContext.openFileInput("mylist.txt"), "UTF8"));
str2 = localBufferedReader.readLine();
if (str2 == null)
{
i = 0;
if (i < localList.size())
break label225;
return localObject;
}
}
catch (Exception localException1)
{
try
{
while (true)
{
String str2;
int m = Integer.parseInt(str2);
k = m;
if (k != 0)
continue;
localArrayList.add(str2.toLowerCase().trim());
}
localException1 = localException1;
}
catch (Exception localException2)
{
while (true)
int k = 0;
}
str1 = String.valueOf(localList.get(i)).toLowerCase().tri m();
j = 0;
}
while (true)
{
if (j >= localArrayList.size());
while (true)
{
i++;
break;
if (str1.indexOf(((String)localArrayList.get(j)).toLo werCase()) <= -1)
break label292;
localObject = str1;
}
label292: j++;
}
}


public void showMessage(String paramString1, String paramString2)
{
AlertDialog.Builder localBuilder = new AlertDialog.Builder(this);
localBuilder.setCancelable(true);
localBuilder.setTitle(paramString1);
localBuilder.setMessage(paramString2);
localBuilder.show();
}


class DownloadFileFromURL extends AsyncTask<String, String, String>
{
DownloadFileFromURL()
{
}


protected String doInBackground(String[] paramArrayOfString)
{
try
{
URL localURL = new URL(paramArrayOfString[0]);
URLConnection localURLConnection = localURL.openConnection();
localURLConnection.connect();
localURLConnection.getContentLength();
BufferedInputStream localBufferedInputStream = new BufferedInputStream(localURL.openStream(), 8192);
FileOutputStream localFileOutputStream = new FileOutputStream("/data/data/" + Pay.this.getPackageName() + "/files/mylist.txt");
byte[] arrayOfByte = new byte[1024];
long l = 0L;
while (true)
{
int i = localBufferedInputStream.read(arrayOfByte);
if (i == -1)
{
localFileOutputStream.flush();
localFileOutputStream.close();
localBufferedInputStream.close();
break;
}
l += i;
localFileOutputStream.write(arrayOfByte, 0, i);
}
}
catch (Exception localException)
{
Log.e("Error: ", localException.getMessage());
}
return null;
}


protected void onPostExecute(String paramString)
{
}


protected void onPreExecute()
{
super.onPreExecute();
}
}
}

کسی میتونه برام درستش کنه :ناراحت:

Ebrahimkh
شنبه 06 تیر 1394, 15:52 عصر
به اینجا یه سری بزن

http://barnamenevis.org/showthread.php?482457-%D9%81%D8%B1%D8%A7%D8%B1-%D8%A7%D8%B2-%D8%AF%D8%B3%D8%AA-Lucky-Patcher

ehsanh22
شنبه 06 تیر 1394, 21:53 عصر
اینجا هیچکدوم به نتیجه نرسیدن ولی این دوست من رسیده به نتیجه . کسی میتونه برام اصلاحش کنه مثل پایینی