Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/223.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android Billing 4.0.0-无购买结果查询KudetailsAsync()_Android_In App Billing_Android Billing_Play Billing Library_Google Play Billing - Fatal编程技术网

Android Billing 4.0.0-无购买结果查询KudetailsAsync()

Android Billing 4.0.0-无购买结果查询KudetailsAsync(),android,in-app-billing,android-billing,play-billing-library,google-play-billing,Android,In App Billing,Android Billing,Play Billing Library,Google Play Billing,我将Android Studio中的Google Play计费库从3.0.3(运行良好)迁移到4.0.0。 我已经检查了我的Google Play账单,看起来一切正常,SKU状态为活动状态(无红色标志)。 我已经尽力按照迁移说明进行操作@ 到目前为止,我所能找到的只是与Google Play Billing的OK连接,也就是说,在onBillingSetupFinished()方法之后,BillingClient.BillingResponseCode.OK响应良好,没有错误消息 我的问题从调用

我将Android Studio中的Google Play计费库从3.0.3(运行良好)迁移到4.0.0。 我已经检查了我的Google Play账单,看起来一切正常,SKU状态为活动状态(无红色标志)。 我已经尽力按照迁移说明进行操作@

到目前为止,我所能找到的只是与Google Play Billing的OK连接,也就是说,在onBillingSetupFinished()方法之后,BillingClient.BillingResponseCode.OK响应良好,没有错误消息

我的问题从调用querySkuDetailsAsync()开始:这里没有响应,甚至没有错误通知。谷歌网站非常强调这个电话,所以我觉得这就是乐趣的开始

我已经提供了这个问题的示例代码。我已经使用了许多来自堆栈溢出的修复程序,但是现在我真的被卡住了,真的需要它来工作

我的问题代码如下:

'''

/*
//在build.graddle for app module中使用以下库
依赖关系{
def计费_version=“4.0.0”
实现“com.android.billingclient:billing:$billing\u版本”
}
*/
StringBuilder builder4SKUInfo;
私有void get_subscribebe2_字符(){
Subscribe2\u字符\u按钮。setOnClickListener(新视图。OnClickListener(){
@凌驾
公共void onClick(视图v){
//我在这里切换视图的可见性
startConnection(新的BillingClientStateListener()){
//Android Studio自动提示生成onBillingSetupFinished和onBillingServiceDisconnected
@凌驾
公共无效onBillingSetupFinished(@NonNull BillingResult billingResultC){
if(billingResultC.getResponseCode()==BillingClient.BillingResponseCode.OK){
//BillingResponseCode在这里很好:工作很好!
//问题从下面开始
String skuToSell=“MySKU_Character_001”;//在我的项目中,SKU是从Google Play控制台剪切粘贴的
List skuList=newarraylist();
skuList.add(skuToSell);
SkuDetailsParams.Builder参数=SkuDetailsParams
.newBuilder()
.库存清单(sku_详细信息)//
.setType(BillingClient.SkuType.SUBS);
billingClient.querySkuDetailsAsync(params.build(),
新SkuDetailsResponseListener(){
@凌驾
公共无效onSkuDetailsResponse(@NonNull BillingResult BillingResult,@NonNull List PurchaseDetailsList){
//没什么!没有得到比林格尔结果
//问题似乎在这一点上得到了解决
如果(PurchaseDetailsList.size()>0){
//没什么!没变大
用于(SKU详情采购SKU\U信息:采购详情列表){
builder4SKUInfo=新的StringBuilder(300);
if(PurchaseSKU_Info.getSku()包含(“MySKU_字符_001”)){
字符串getSKUInfo=(
“\n标题[查询]:”+PurchaseSKU_Info.getTitle()
+“\n\n详细信息:”+PurchaseSKU_Info.getDescription()
+“\n\n说明:”+PurchaseSKU\u Info.getSubscriptionPeriod()
+“\n\n定价”+PurchaseSKU_Info.getPrice()
+“\n\n避免问题:\n更新Google Play上的订阅设置”
+“\n\n重要事项:不可转让”
+“\n\n仅适用于此设备\n”);
//+“\n其他SKU:”+SKU\u Info.getSku()
//“001=“+billingResultB.getResponseCode()
//+“\n列表大小:”+PurchaseDetailsList.Size());
builder4SKUInfo.append(getSKUInfo);//我需要在其他地方使用的结果
}
}
}else if(billingResult.getResponseCode()==BillingClient.BillingResponseCode.ITEM_已拥有){
//谷歌对此没有回应
}else if(billingResult.getResponseCode()==BillingClient.BillingResponseCode.ITEM\u未拥有){
//谷歌对此没有回应
}else if(billingResult.getResponseCode()==BillingClient.BillingResponseCode.USER\u已取消){
//对取消做些什么
}else if(billingResult.getResponseCode()==BillingClient.BillingResponseCode.BILLING\u不可用){
//谷歌对此没有回应
}else if(billingResult.getResponseCode()==BillingClient.BillingResponseCode.SERVICE\u已断开连接){
//谷歌对此没有回应
}else if(billingResult.getResponseCode()==Bill
/*
//Using the following library in build.graddle for app module
    dependencies {
        def billing_version = "4.0.0"
        implementation "com.android.billingclient:billing:$billing_version"
}

*/

StringBuilder builder4SKUInfo;
private void get_Subscribe2_Characters() {

    Subscribe2_Characters_Button.setOnClickListener(new View.OnClickListener() {

        @Override
        public void onClick(View v) {

            //I Toggle Visibility of Views Here


            billingClient.startConnection(new BillingClientStateListener() {

                //Android Studio auto-prompts to generate onBillingSetupFinished & onBillingServiceDisconnected

                @Override
                public void onBillingSetupFinished(@NonNull BillingResult billingResultC) {
                    if (billingResultC.getResponseCode() == BillingClient.BillingResponseCode.OK) {

                        //BillingResponseCode is OK here: Works Just Fine!
                        //The problem starts below


                        String skuToSell = "MySKU_Character_001"; //In my project, the SKU is cut-pasted from Google Play Console
                        List<String> skuList = new ArrayList<> ();
                        skuList.add(skuToSell);


                        SkuDetailsParams.Builder params = SkuDetailsParams
                                .newBuilder()
                                .setSkusList(sku_Details)  //
                                .setType(BillingClient.SkuType.SUBS);

                        billingClient.querySkuDetailsAsync(params.build(),
                                new SkuDetailsResponseListener() {
                                    @Override
                                    public void onSkuDetailsResponse(@NonNull BillingResult billingResult, @NonNull List<SkuDetails> PurchaseDetailsList) {

                                        //NOTHING!  Not getting BillingResult
                                        //Problem seems to at this point

                                        if (PurchaseDetailsList.size() > 0) {

                                            //NOTHING!  Not getting size

                                            for (SkuDetails PurchaseSKU_Info : PurchaseDetailsList) {

                                                builder4SKUInfo = new StringBuilder(300);

                                                if (PurchaseSKU_Info.getSku().contains("MySKU_Character_001")) {


                                                    String getSKUInfo = (
                                                            "\nTitle [Query]: " + PurchaseSKU_Info.getTitle()
                                                                    + "\n\nDetails: " + PurchaseSKU_Info.getDescription()
                                                                    + "\n\nDuration: " + PurchaseSKU_Info.getSubscriptionPeriod()
                                                                    + "\n\nPrice" + PurchaseSKU_Info.getPrice()
                                                                    + "\n\nAvoid Problems:\nUpdated Subscription Settings on Google Play"
                                                                    + "\n\nIMPORTANT: NOT Transferable"
                                                                    + "\n\n      For this device only\n");
                                                    //+ "\nOther SKUs: " + SKU_Info.getSku()
                                                    //"001 = " + billingResultB.getResponseCode()
                                                    //+ "\nList Size: " + PurchaseDetailsList.size());

                                                    builder4SKUInfo.append(getSKUInfo); //The result I need to use elsewhere

                                                }
                                            }
                                        } else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED) {

                                            //No Google Play response for this

                                        } else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.ITEM_NOT_OWNED) {

                                            //No Google Play response for this


                                        }  else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.USER_CANCELED) {

                                            //Do something about cancels

                                        } else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.BILLING_UNAVAILABLE) {

                                            //No Google Play response for this

                                        } else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.SERVICE_DISCONNECTED) {

                                            //No Google Play response for this

                                        } else if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.SERVICE_TIMEOUT) {

                                            //No Google Play response for this

                                        } else {

                                            //Following Toast does not show

                                            String SomethingWrong = "Somethings is Wrong" +
                                                    "\nUpdate Your Google Play Billing Info" +
                                                    "\nCheck Internet Connection";

                                            Toast.makeText(KH.this, SomethingWrong, Toast.LENGTH_LONG).show();

                                        }
                                    }
                                });
                    }
                }


                @Override
                public void onBillingServiceDisconnected() {

                    //Following Toast does not show

                    String BillingServiceDisconnected = "Billing Service Disconnected" +
                            "\nUpdate Your Google Play Billing Info" +
                            "\nCheck Internet Connection";

                    Toast.makeText(KH.this, BillingServiceDisconnected, Toast.LENGTH_LONG).show();

                }
            });
        }
    });
}