use of com.huawei.hms.iap.entity.StartIapActivityReq in project Osmand by osmandapp.
the class IapRequestHelper method showSubscription.
/**
* link to subscription manager page
* @param activity activity
* @param productId the productId of the subscription product
*/
public static void showSubscription(final Activity activity, String productId) {
StartIapActivityReq req = new StartIapActivityReq();
if (TextUtils.isEmpty(productId)) {
req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_MANAGER_ACTIVITY);
} else {
req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_EDIT_ACTIVITY);
req.setSubscribeProductId(productId);
}
IapClient iapClient = Iap.getIapClient(activity);
Task<StartIapActivityResult> task = iapClient.startIapActivity(req);
task.addOnSuccessListener(new OnSuccessListener<StartIapActivityResult>() {
@Override
public void onSuccess(StartIapActivityResult result) {
if (result != null) {
result.startActivity(activity);
}
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
ExceptionHandle.handle(activity, e);
}
});
}
use of com.huawei.hms.iap.entity.StartIapActivityReq in project Osmand by osmandapp.
the class InAppPurchaseHelperImpl method manageSubscription.
@Override
public void manageSubscription(@NonNull Context ctx, @Nullable String sku) {
if (uiActivity != null) {
StartIapActivityReq req = new StartIapActivityReq();
if (!Algorithms.isEmpty(sku)) {
req.setSubscribeProductId(sku);
req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_EDIT_ACTIVITY);
} else {
req.setType(StartIapActivityReq.TYPE_SUBSCRIBE_MANAGER_ACTIVITY);
}
Task<StartIapActivityResult> task = getIapClient().startIapActivity(req);
task.addOnSuccessListener(result -> {
logDebug("startIapActivity: onSuccess");
Activity activity = (Activity) uiActivity;
if (result != null && AndroidUtils.isActivityNotDestroyed(activity)) {
result.startActivity(activity);
}
}).addOnFailureListener(e -> logDebug("startIapActivity: onFailure"));
}
}
Aggregations