Search in sources :

Example 1 with IabHelper

use of com.codename1.payments.v3.IabHelper in project CodenameOne by codenameone.

the class CodenameOneActivity method onCreate.

@Override
public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    AndroidImplementation.setActivity(this);
    AndroidNativeUtil.onCreate(savedInstanceState);
    if (android.os.Build.VERSION.SDK_INT >= 11) {
        getWindow().requestFeature(Window.FEATURE_ACTION_BAR);
        getActionBar().hide();
    }
    try {
        if (isBillingEnabled()) {
            String k = getBase64EncodedPublicKey();
            if (k.length() == 0) {
                Log.e("Codename One", "android.licenseKey base64 is not configured");
            }
            mHelper = new IabHelper(this, getBase64EncodedPublicKey());
            mHelper.enableDebugLogging(true);
            mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {

                public void onIabSetupFinished(IabResult result) {
                    if (!result.isSuccess()) {
                        // Oh noes, there was a problem.
                        Log.e("Codename One", "Problem setting up in-app billing: " + result);
                        return;
                    }
                    // Have we been disposed of in the meantime? If so, quit.
                    if (mHelper == null) {
                        return;
                    }
                    // IAB is fully set up. Now, let's get an inventory of stuff we own.
                    mHelper.queryInventoryAsync(mGotInventoryListener);
                }
            });
        }
    } catch (Throwable t) {
        // might happen if billing permissions are missing
        System.out.print("This exception is totally valid and here only for debugging purposes");
        t.printStackTrace();
    }
}
Also used : IabResult(com.codename1.payments.v3.IabResult) IabHelper(com.codename1.payments.v3.IabHelper)

Aggregations

IabHelper (com.codename1.payments.v3.IabHelper)1 IabResult (com.codename1.payments.v3.IabResult)1