Android沙箱在有订阅时不返回任何数据。
创始人
2024-10-10 08:00:57
0

为了在Android沙箱中获得订阅相关数据,您需要先解除其绑定,然后再查询数据。以下是一些样例代码示例,可以用来解决这个问题:

// 解绑之前的订阅
final String subscriptionId = "your_subscription_id";
final BillingClient billingClient = BillingClient.newBuilder(context).enablePendingPurchases().build();
billingClient.startConnection(new BillingClientStateListener() {
    @Override
    public void onBillingSetupFinished(BillingResult billingResult) {
        if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
            billingClient.queryPurchases(BillingClient.SkuType.SUBS).getPurchasesList()
                    .stream().filter(p -> p.getSkus().contains(subscriptionId))
                    .forEach(p -> {
                        billingClient.acknowledgePurchase(AcknowledgePurchaseParams.newBuilder()
                                .setPurchaseToken(p.getPurchaseToken()).build(), new AcknowledgePurchaseResponseListener() {
                            @Override
                            public void onAcknowledgePurchaseResponse(BillingResult billingResult) {
                                if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
                                    Log.d(TAG, "Consumed purchase for subscription id: " + subscriptionId);
                                } else {
                                    Log.e(TAG, "Failed to acknowledge purchase for subscription id: " + subscriptionId);
                                }
                            }
                        });
                    });;
        } else {
            Log.e(TAG, "Failed to connect to billing client");
        }
    }

    @Override
    public void onBillingServiceDisconnected() {
        Log.e(TAG, "Billing client disconnected");
    }
});

// 查询有关订阅的数据
billingClient.queryPurchaseHistory(BillingClient.SkuType.SUBS).getPurchaseHistoryRecordList().stream()
        .filter(p -> p.getSkus().contains(subscriptionId))
        .forEach(p -> Log.d(TAG, "Got purchase info for subscription id: " + subscriptionId + " with purchase time: " + p.getPurchaseTime()));

通过这些代码,您可以在Android沙箱中成功查询到订阅相关的数据。

相关内容

热门资讯

透视黑科技"uupo... 透视黑科技"uupoker有透视吗"详细辅助扑克教程(万能挂攻略);原来确实真的有挂(需添加指定薇1...
透视最新"智星德州可... 透视最新"智星德州可以透视吗"详细辅助可靠技巧(透视脚本苹果版软件);原来确实真的有挂(需添加指定薇...
透视软件"德州局hh... 透视软件"德州局hhpoker"详细辅助2025新版总结(透视脚本是有挂攻略);最新版2024是一款...
透视能赢"wepok... 透视能赢"wepoker免费透视"详细辅助解密教程(透视破解版技巧)关于wepoker免费透视机制的...
透视模拟器"wepo... 透视模拟器"wepoker怎么提高运气"详细辅助必备教程(可以拿到好牌技巧)1、很好的工具软件,可以...
透视软件"wepok... 1、透视软件"wepokerplus作弊"详细辅助教你攻略(黑侠辅助器正版下载方法)2、进入游戏-大...
透视游戏"德普之星私... 1、透视游戏"德普之星私人局透视"详细辅助细节揭秘(私局代打技巧)。2、德普之星私人局透视透视辅助简...
透视辅助"智星德州辅... 1、透视辅助"智星德州辅助译码插件靠谱吗"详细辅助新版2025教程(亲友圈有用软件)。2、智星德州辅...
透视挂透视"智星菠萝... 透视挂透视"智星菠萝辅助"详细辅助wepoke教程(免费透视脚本技巧);实战中需综合运用上述技巧,并...
透视工具"epoke... 透视工具"epoker免费透视脚本"详细辅助可靠教程(辅助器免费透视);亲真的是有正版授权,小编(透...