List of usage examples for android.app PendingIntent getIntentSender
public IntentSender getIntentSender()
From source file:Main.java
private static IntentSender createIntentSender(Context context, int sessionId) { PendingIntent pendingIntent = PendingIntent.getBroadcast(context, sessionId, new Intent(ACTION_INSTALL_COMPLETE), 0); return pendingIntent.getIntentSender(); }
From source file:org.qtproject.example.hangman.HangmanActivity.java
public static void buyVowel(char vowel) { if (m_instance.m_service == null) { Log.e(QtApplication.QtTAG, "Buying vowel failed: No billing service"); return;//from w ww .j a v a2 s. c o m } try { Bundle buyIntentBundle = m_instance.m_service.getBuyIntent(3, m_instance.getPackageName(), "vowel", "inapp", "" + vowel); int responseCode = buyIntentBundle.getInt("RESPONSE_CODE"); if (responseCode == 0) { PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); m_instance.startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); return; } else { Log.e(QtApplication.QtTAG, "Buying vowel failed: Response code == " + responseCode); } } catch (Exception e) { Log.e(QtApplication.QtTAG, "Exception caught when buying vowel!", e); } }
From source file:net.gcompris.GComprisActivity.java
public static void buyGCompris() { if (m_instance.m_service == null) { Log.e(QtApplication.QtTAG, "Buying full version failed: No billing service"); return;/*from w ww. ja v a 2s.c o m*/ } try { Bundle buyIntentBundle = m_instance.m_service.getBuyIntent(3, m_instance.getPackageName(), SKU_NAME, "inapp", ""); int responseCode = buyIntentBundle.getInt("RESPONSE_CODE"); if (responseCode == 0 /* BILLING_RESPONSE_RESULT_OK */) { PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); m_instance.startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), Integer.valueOf(0), Integer.valueOf(0), Integer.valueOf(0)); return; } else if (responseCode == 7 /* BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED */) { bought(true); } else { Log.e(QtApplication.QtTAG, "Buying full version failed: Response code == " + responseCode); } } catch (Exception e) { Log.e(QtApplication.QtTAG, "Exception caught when buying full version!", e); } }
From source file:de.j4velin.mapsmeasure.Dialogs.java
/** * @param c the Context// w w w .j a va 2s. com * @return a dialog allowing the user to gain access to the evelation * feature */ public static Dialog getElevationAccessDialog(final Map c, final IInAppBillingService service) { AlertDialog.Builder builder = new AlertDialog.Builder(c); builder.setMessage(R.string.buy_pro); builder.setPositiveButton(android.R.string.ok, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { try { Bundle buyIntentBundle = service.getBuyIntent(3, c.getPackageName(), "de.j4velin.mapsmeasure.billing.pro", "inapp", c.getPackageName()); if (buyIntentBundle.getInt("RESPONSE_CODE") == 0) { PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); c.startIntentSenderForResult(pendingIntent.getIntentSender(), 42, null, 0, 0, 0); } } catch (Exception e) { Toast.makeText(c, e.getClass().getName() + ": " + e.getMessage(), Toast.LENGTH_LONG).show(); e.printStackTrace(); } dialog.dismiss(); } }); builder.setNegativeButton(android.R.string.cancel, new DialogInterface.OnClickListener() { @Override public void onClick(final DialogInterface dialog, int which) { dialog.dismiss(); } }); return builder.create(); }
From source file:org.wso2.iot.agent.api.ApplicationManager.java
private static IntentSender createIntentSender(Context context, int sessionId, String packageName) { Intent intent = new Intent(ACTION_INSTALL_COMPLETE); intent.putExtra("packageName", packageName); PendingIntent pendingIntent = PendingIntent.getBroadcast(context, sessionId, intent, 0); return pendingIntent.getIntentSender(); }
From source file:net.robotmedia.billing.BillingController.java
/** * Starts the specified purchase intent with the specified activity. * // www.j a va 2s . co m * @param activity * @param purchaseIntent * purchase intent. * @param intent */ public static void startPurchaseIntent(Activity activity, PendingIntent purchaseIntent, Intent intent) { if (Compatibility.isStartIntentSenderSupported()) { // This is on Android 2.0 and beyond. The in-app buy page activity // must be on the activity stack of the application. Compatibility.startIntentSender(activity, purchaseIntent.getIntentSender(), intent); } else { // This is on Android version 1.6. The in-app buy page activity must // be on its own separate activity stack instead of on the activity // stack of the application. try { purchaseIntent.send(activity, 0 /* code */, intent); } catch (CanceledException e) { Log.e(LOG_TAG, "Error starting purchase intent", e); } } }
From source file:io.octo.bear.pago.BillingActivity.java
private void startPurchaseFlow(PendingIntent buyIntent) { try {/* ww w . jav a2 s . c om*/ startIntentSenderForResult(buyIntent.getIntentSender(), REQUEST_CODE, new Intent(), 0, 0, 0); } catch (IntentSender.SendIntentException e) { Log.e(TAG, "onCreate: ", e); } }
From source file:net.kourlas.voipms_sms.Billing.java
private void showDonationDialog(Activity sourceActivity) { try {/*from w w w. j a va 2 s . c o m*/ Bundle buyIntentBundle = billingService.getBuyIntent(3, applicationContext.getPackageName(), applicationContext.getString(R.string.billing_pid_donation), "inapp", null); PendingIntent pendingIntent = buyIntentBundle.getParcelable("BUY_INTENT"); sourceActivity.startIntentSenderForResult(pendingIntent.getIntentSender(), 1001, new Intent(), 0, 0, 0); } catch (Exception ex) { Utils.showInfoDialog(sourceActivity, applicationContext.getString(R.string.billing_failure)); } }
From source file:jp.alessandro.android.iab.PurchaseFlowLauncher.java
private void startBuyIntent(final Activity activity, final PendingIntent pendingIntent, int requestCode) throws BillingException { IntentSender sender = pendingIntent.getIntentSender(); try {//w ww . j ava 2s . c o m activity.startIntentSenderForResult(sender, requestCode, new Intent(), 0, 0, 0); } catch (IntentSender.SendIntentException e) { throw new BillingException(Constants.ERROR_SEND_INTENT_FAILED, e.getMessage()); } }
From source file:angeloid.dreamnarae.TTS_Biling.java
void Biling_Friends() { try {/*from ww w. j a v a 2s . c o m*/ // 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) { } }