Example usage for android.app PendingIntent getIntentSender

List of usage examples for android.app PendingIntent getIntentSender

Introduction

In this page you can find the example usage for android.app PendingIntent getIntentSender.

Prototype

public IntentSender getIntentSender() 

Source Link

Document

Retrieve a IntentSender object that wraps the existing sender of the PendingIntent

Usage

From source file:angeloid.dreamnarae.TTS_Biling.java

void Biling_Narae() {
    try {//w w w  . jav a  2 s .com
        // Query Already Purchased
        Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        int response = ownedItems.getInt("RESPONSE_CODE");
        ArrayList<String> ownedSkus = null;

        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

        // Purchase it

        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp", "");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                Integer.valueOf(0), Integer.valueOf(0));

        // Check
        ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);
        response = ownedItems.getInt("RESPONSE_CODE");
        if (response == 0)
            ownedSkus = ownedItems.getStringArrayList("INAPP_PURCHASE_ITEM_LIST");

        if (response == 0 && ownedSkus.size() > 0 && ownedSkus.get(0).equals(sku)) {
            SharedPreferences sharedPref = PreferenceManager.getDefaultSharedPreferences(this);
            SharedPreferences.Editor editor = sharedPref.edit();
            editor.putInt("License", TRUE);
            editor.commit();
            isPro = true;
        }

    } catch (Exception e) {
    }
}

From source file:com.skubit.android.example.MainActivity.java

public void makePurchase(Map<String, String> map) {
    if (mService == null) {
        return;/*from   ww  w. j  av  a 2s .co  m*/
    }
    try {
        Bundle buyIntent = mService.getBuyIntent(1, getApplicationContext().getPackageName(), map.get("id"),
                "donation", "developerPayload: " + Math.random());
        PendingIntent pendingIntent = buyIntent.getParcelable("BUY_INTENT");

        startIntentSenderForResult(pendingIntent.getIntentSender(), map.get("id").hashCode(), new Intent(), 0,
                0, 0);

    } catch (RemoteException | SendIntentException e) {
        e.printStackTrace();
    }
}

From source file:com.duguang.baseanimation.ui.listivew.listviews.ListViewsMainActivity.java

private void buy(String sku) {
    try {//from ww w .j  a v a2 s. c  o m
        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp",
                "bGoa+V7g/ysDXvKwqq+JTFn4uQZbPiQJo4pf9RzJ");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        if (pendingIntent != null) {
            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                    Integer.valueOf(0), Integer.valueOf(0));
        }
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (SendIntentException e) {
        e.printStackTrace();
    }
}

From source file:com.haarman.listviewanimations.MainActivity.java

private void buy(final String sku) {
    try {//w  ww  .  ja  va2  s  .  c  o m
        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), sku, "inapp",
                "bGoa+V7g/ysDXvKwqq+JTFn4uQZbPiQJo4pf9RzJ");
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        if (pendingIntent != null) {
            startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), 0, 0, 0);
        }
    } catch (RemoteException | SendIntentException ignored) {
        Toast.makeText(this, getString(R.string.exception), Toast.LENGTH_LONG).show();
    }
}

From source file:net.zionsoft.obadiah.model.InAppBillingHelper.java

public void purchaseAdsRemoval(final OnAdsRemovalPurchasedListener onPurchased) {
    if (mStatus != Status.INITIALIZED) {
        Analytics.trackException("Failed to purchase ads removal - Not initialized");
        onPurchased.onAdsRemovalPurchased(false);
        return;/*from   w  w w  .j av a 2  s.  co  m*/
    }

    try {
        // TODO verifies signature

        final Bundle buyIntent = mInAppBillingService.getBuyIntent(BILLING_VERSION, mContext.getPackageName(),
                mContext.getString(R.string.in_app_product_no_ads), ITEM_TYPE_INAPP, null);
        final int response = buyIntent.getInt("RESPONSE_CODE");
        if (response == BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED) {
            onPurchased.onAdsRemovalPurchased(true);
            return;
        }
        if (response != BILLING_RESPONSE_RESULT_OK) {
            Analytics.trackException("Failed to purchase ads removal - " + response);
            onPurchased.onAdsRemovalPurchased(false);
            return;
        }

        mOnAdsRemovalPurchased = onPurchased;
        final PendingIntent pendingIntent = buyIntent.getParcelable("BUY_INTENT");
        mContext.startIntentSenderForResult(pendingIntent.getIntentSender(), REQUEST_PURCHASE, new Intent(), 0,
                0, 0);
    } catch (Exception e) {
        Crashlytics.logException(e);
        onPurchased.onAdsRemovalPurchased(false);
    }
}

From source file:org.solovyev.android.checkout.PurchaseFlow.java

@Override
public void onSuccess(@Nonnull PendingIntent purchaseIntent) {
    if (listener == null) {
        // request was cancelled => stop here
        return;//from  www  .ja  va 2  s. co  m
    }
    try {
        activity.startIntentSenderForResult(purchaseIntent.getIntentSender(), requestCode, new Intent(), 0, 0,
                0);
    } catch (RuntimeException e) {
        handleError(e);
    } catch (IntentSender.SendIntentException e) {
        handleError(e);
    }
}

From source file:com.subzero.runners.android.AndroidLauncher.java

@Override
public void makePurchase(String itemID, Preferences pref) {
    this.pref = pref;
    try {/*w w  w.j  a  v  a  2s  . c  o m*/
        Bundle buyIntentBundle = mService.getBuyIntent(3, getPackageName(), itemID, "inapp", null);
        PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");
        startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0),
                Integer.valueOf(0), Integer.valueOf(0));
    } catch (RemoteException e) {
        e.printStackTrace();
    } catch (SendIntentException e) {
        e.printStackTrace();
    }
}

From source file:net.olejon.mdapp.DonateActivity.java

private void makeDonation(String product) {
    try {//  w  w  w .ja v a2 s. c o m
        Bundle bundle = mIInAppBillingService.getBuyIntent(3, getPackageName(), product, "inapp", "");
        PendingIntent pendingIntent = bundle.getParcelable("BUY_INTENT");

        startIntentSenderForResult(pendingIntent.getIntentSender(), 1, new Intent(), 0, 0, 0);
    } catch (Exception e) {
        new MaterialDialog.Builder(mContext).title(getString(R.string.device_not_supported_dialog_title))
                .content(getString(R.string.device_not_supported_dialog_message))
                .positiveText(getString(R.string.device_not_supported_dialog_positive_button))
                .contentColorRes(R.color.black).positiveColorRes(R.color.dark_blue).show();
    }
}

From source file:com.tangrainc.inappbilling.InAppBillingHelper.java

public void startBuyIntent(Activity foregroundActivity, String productIdentifier, String payload)
        throws Exception {
    Bundle buyIntentBundle = _service.getBuyIntent(3, _context.getPackageName(), productIdentifier, "inapp",
            payload);/*from ww w .j ava 2s  .  co  m*/
    PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT");

    if (pendingIntent == null) {
        throw new Exception("Product already purchased!");
    }

    foregroundActivity.startIntentSenderForResult(pendingIntent.getIntentSender(), BUY_INTENT_REQUEST_CODE,
            new Intent(), 0, 0, 0);
}

From source file:com.zd.vpn.fragments.AboutFragment.java

private void triggerBuy(String sku) {
    try {//from  w  ww . j a  v  a  2s. c  om
        Bundle buyBundle = mService.getBuyIntent(3, getActivity().getPackageName(), sku, INAPPITEM_TYPE_INAPP,
                "Thanks for the donation! :)");

        if (buyBundle.getInt(RESPONSE_CODE) == BILLING_RESPONSE_RESULT_OK) {
            PendingIntent buyIntent = buyBundle.getParcelable(RESPONSE_BUY_INTENT);
            getActivity().startIntentSenderForResult(buyIntent.getIntentSender(), DONATION_CODE, new Intent(),
                    0, 0, 0);
        }

    } catch (RemoteException e) {
        VpnStatus.logException(e);
    } catch (IntentSender.SendIntentException e) {
        VpnStatus.logException(e);
    }
}