با سلام من این کد های رو نوشتم ولی ارور فورز کلوز میده عیب از کجاست؟;
import util.IabHelper;
import util.IabResult;
import util.Inventory;
import util.Purchase;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
public class Hem extends Activity {
Button btn1;
// Debug tag, for logging
static final String TAG = "hkgik";
// SKUs for our products: the premium upgrade (non-consumable)
static final String SKU_PREMIUM = "khgbjg";
// Does the user have the premium upgrade?
boolean mIsPremium = false;
// (arbitrary) request code for the purchase flow
static final int RC_REQUEST = 10001;
// The helper object
IabHelper mHelper;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.par);
btn1 = (Button) findViewById(R.id.button1);
String base64EncodedPublicKey = "MIHNMA0GCSqGSIb3DQEsV61HZVcwUDUkQwIaiF82nNcJC jZo/dodfmiYh7JHpALWOvVYZDaVPHjlWeI+GHP1D2P2XXRx2KhNHl8 mw2yI9QHt4tzz52nY+lJhwO4QVRfCT0i6sOMjKnknMjd+0iYDT/mGHmR4ef3D+blBXIPA+VvEny9nPprhntBeZHODYQ+UT3KrShF8 nHxrHuQFG+9PJeR6ok8+ZQTFKrECAwEAAQ==";
// 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);
}
// Hooray, IAB is fully set up!
mHelper.queryInventoryAsync(mGotInventoryListener) ;
}
});
}
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);
return;
}
else {
Log.d(TAG, "Query inventory was successful.");
mIsPremium = inventory.hasPurchase(SKU_PREMIUM);
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
}
Log.d(TAG, "Initial inventory query finished; enabling main UI.");
}
};
public void onUpgradeAppButtonClicked(View arg0) {
Log.d(TAG, "Upgrade button clicked; launching purchase flow for upgrade.");
/* TODO: for security, generate your payload here for verification. See the comments on
* verifyDeveloperPayload() for more info. Since this is a SAMPLE, we just use
* an empty string, but on a production app you should carefully generate this. */
String payload = "qwertyuiop";
mHelper.launchPurchaseFlow(this, SKU_PREMIUM, RC_REQUEST,
mPurchaseFinishedListener, "qwertyuiop");
}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
super.onActivityResult(requestCode, resultCode, data);
Log.d(TAG, "onActivityResult(" + requestCode + "," + resultCode + "," + data);
// 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.");
}
}
boolean verifyDeveloperPayload(Purchase p) {
String payload = p.getDeveloperPayload();
return true;
}
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
if (result.isFailure()) {
Toast.makeText(getApplicationContext(), R.string.parfaild, Toast.LENGTH_SHORT).show();
return;
}
if (!verifyDeveloperPayload(purchase)) {
Toast.makeText(getApplicationContext(), R.string.parfaild, Toast.LENGTH_SHORT).show();
return;
}
if (purchase.getSku().equals(SKU_PREMIUM)) {
Toast.makeText(getApplicationContext(), R.string.parmof, Toast.LENGTH_SHORT).show();
mIsPremium = true;
}
}
};
@Override
public void onDestroy() {
super.onDestroy();
Log.d(TAG, "Destroying helper.");
if (mHelper != null) mHelper.dispose();
mHelper = null;
}
}