| 155 | } |
| 156 | |
| 157 | public PendingIntent getBuyIntent(String sku, boolean subscription) throws RemoteException { |
| 158 | if (service == null) |
| 159 | return null; |
| 160 | Bundle bundle = service.getBuyIntent(IAB_VERSION, context.getPackageName(), sku, subscription ? "subs" : "inapp", "netguard"); |
| 161 | Log.i(TAG, "getBuyIntent sku=" + sku + " subscription=" + subscription); |
| 162 | Util.logBundle(bundle); |
| 163 | int response = (bundle == null ? -1 : bundle.getInt("RESPONSE_CODE", -1)); |
| 164 | Log.i(TAG, "Response=" + getResult(response)); |
| 165 | if (response != 0) |
| 166 | throw new IllegalArgumentException(getResult(response)); |
| 167 | if (!bundle.containsKey("BUY_INTENT")) |
| 168 | throw new IllegalArgumentException("BUY_INTENT missing"); |
| 169 | return bundle.getParcelable("BUY_INTENT"); |
| 170 | } |
| 171 | |
| 172 | public static void setBought(String sku, Context context) { |
| 173 | Log.i(TAG, "Bought " + sku); |