use of com.huawei.hmf.tasks.OnFailureListener in project Osmand by osmandapp.
the class IapRequestHelper method obtainOwnedPurchaseRecord.
/**
* obtain the historical consumption information about a consumable in-app product or all subscription receipts of a subscription.
* @param iapClient IapClient instance to call the obtainOwnedPurchaseRecord API.
* @param priceType In-app product type.
* The value contains: 0: consumable 1: non-consumable 2 auto-renewable subscription.
* @param continuationToken Data locating flag for supporting query in pagination mode.
* @param callback IapApiCallback
*/
public static void obtainOwnedPurchaseRecord(IapClient iapClient, int priceType, String continuationToken, final IapApiCallback callback) {
Log.i(TAG, "call obtainOwnedPurchaseRecord");
Task<OwnedPurchasesResult> task = iapClient.obtainOwnedPurchaseRecord(createOwnedPurchasesReq(priceType, continuationToken));
task.addOnSuccessListener(new OnSuccessListener<OwnedPurchasesResult>() {
@Override
public void onSuccess(OwnedPurchasesResult result) {
Log.i(TAG, "obtainOwnedPurchaseRecord, success");
callback.onSuccess(result);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e(TAG, "obtainOwnedPurchaseRecord, fail");
callback.onFail(e);
}
});
}
use of com.huawei.hmf.tasks.OnFailureListener 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.hmf.tasks.OnFailureListener in project Osmand by osmandapp.
the class IapRequestHelper method isEnvReady.
/**
* To check whether the country or region of the logged in HUAWEI ID is included in the countries or regions supported by HUAWEI IAP.
* @param mClient IapClient instance to call the isEnvReady API.
* @param callback IapApiCallback.
*/
public static void isEnvReady(IapClient mClient, final IapApiCallback callback) {
Log.i(TAG, "call isEnvReady");
Task<IsEnvReadyResult> task = mClient.isEnvReady();
task.addOnSuccessListener(new OnSuccessListener<IsEnvReadyResult>() {
@Override
public void onSuccess(IsEnvReadyResult result) {
Log.i(TAG, "isEnvReady, success");
callback.onSuccess(result);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e(TAG, "isEnvReady, fail");
callback.onFail(e);
}
});
}
use of com.huawei.hmf.tasks.OnFailureListener in project Osmand by osmandapp.
the class IapRequestHelper method createPurchaseIntent.
public static void createPurchaseIntent(final IapClient iapClient, String productId, int type, String payload, final IapApiCallback callback) {
Log.i(TAG, "call createPurchaseIntent");
PurchaseIntentReq req = createPurchaseIntentReq(type, productId);
req.setDeveloperPayload(payload);
Task<PurchaseIntentResult> task = iapClient.createPurchaseIntent(req);
task.addOnSuccessListener(new OnSuccessListener<PurchaseIntentResult>() {
@Override
public void onSuccess(PurchaseIntentResult result) {
Log.i(TAG, "createPurchaseIntent, success");
callback.onSuccess(result);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e(TAG, "createPurchaseIntent, fail");
callback.onFail(e);
}
});
}
use of com.huawei.hmf.tasks.OnFailureListener in project Osmand by osmandapp.
the class IapRequestHelper method obtainProductInfo.
/**
* Obtain in-app product details configured in AppGallery Connect.
* @param iapClient IapClient instance to call the obtainProductInfo API.
* @param productIds ID list of products to be queried. Each product ID must exist and be unique in the current app.
* @param type In-app product type.
* The value contains: 0: consumable 1: non-consumable 2 auto-renewable subscription
* @param callback IapApiCallback
*/
public static void obtainProductInfo(IapClient iapClient, final List<String> productIds, int type, final IapApiCallback callback) {
Log.i(TAG, "call obtainProductInfo");
Task<ProductInfoResult> task = iapClient.obtainProductInfo(createProductInfoReq(type, productIds));
task.addOnSuccessListener(new OnSuccessListener<ProductInfoResult>() {
@Override
public void onSuccess(ProductInfoResult result) {
Log.i(TAG, "obtainProductInfo, success");
callback.onSuccess(result);
}
}).addOnFailureListener(new OnFailureListener() {
@Override
public void onFailure(Exception e) {
Log.e(TAG, "obtainProductInfo, fail");
callback.onFail(e);
}
});
}
Aggregations