/** * @param activity The AndroidApplication activity. * @param requestCode The request code to use in case they are needed (not all stores need them). */ public IAP (Activity activity, int requestCode) { // are we on GooglePlay? try { Class<?> googlePlayClazz = Class.forName("com.badlogic.gdx.pay.android.googleplay.AndroidGooglePlayPurchaseManager"); Method method = googlePlayClazz.getMethod("isRunningViaGooglePlay", Activity.class); if ((Boolean)method.invoke(googlePlayClazz, activity)) { // we are running on GooglePlay: let's set the purchase manager and be done with it! PurchaseSystem.setManager((PurchaseManager)googlePlayClazz.getConstructor(Activity.class, int.class).newInstance(activity, requestCode)); return; } } catch (Exception e) { Log.d(TAG, "Failed to locate purchase manager for GooglePlay (gdx-pay-android-googleplay.jar file not installed)", e); } }
/** * @param activity The AndroidApplication activity. * @param requestCode The request code to use in case they are needed (not all stores need them). */ public IAP (Activity activity, int requestCode) { // are we on GooglePlay? try { Class<?> googlePlayClazz = Class.forName("com.badlogic.gdx.pay.android.googleplay.AndroidGooglePlayPurchaseManager"); Method method = googlePlayClazz.getMethod("isRunningViaGooglePlay", Activity.class); if ((Boolean)method.invoke(googlePlayClazz, activity)) { // we are running on GooglePlay: let's set the purchase manager and be done with it! PurchaseSystem.setManager((PurchaseManager)googlePlayClazz.getConstructor(Activity.class, int.class).newInstance(activity, requestCode)); return; } } catch (Exception e) { Log.d(TAG, "Failed to locate purchase manager for GooglePlay (gdx-pay-android-googleplay.jar file not installed)", e); } }
@Before public void setUp() throws Exception { PurchaseSystem.setManager(purchaseManager); }
@SuppressWarnings("unused") // Unit tested with reflection. (as in IAP.java) public AndroidGooglePlayPurchaseManager(Activity activity, AndroidFragmentApplication application, int activityRequestCode) { PurchaseResponseActivityResultConverter converter = new PurchaseResponseActivityResultConverter(this); AsyncExecutor executor = new NewThreadSleepAsyncExecutor(); ApplicationProxy.FragmentProxy proxy = new ApplicationProxy.FragmentProxy(activity, application); googleInAppBillingService = new V3GoogleInAppBillingService(proxy, activityRequestCode, converter, executor); PurchaseSystem.setManager(this); }
PurchaseSystem.setManager((PurchaseManager) ClassReflection.newInstance(iapClazz));