Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/221.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
Java 带回调的Android cordova插件_Java_Android_Ios_Cordova_Phonegap Plugins - Fatal编程技术网

Java 带回调的Android cordova插件

Java 带回调的Android cordova插件,java,android,ios,cordova,phonegap-plugins,Java,Android,Ios,Cordova,Phonegap Plugins,我正在将IOS phonegap插件转换为android。在IOS中有这样一个插件调用 cordova.exec('InAppPurchaseManager.requestProductsData', callbackName, {productIds: productIds}); 这行代码使用本机层从iTunes商店获取产品详细信息。一旦将此消息发送到本机层,它就会发出异步请求以获取产品详细信息。一旦收到产品,它就会发出调用 NSString *js = [NSString stringWi

我正在将IOS phonegap插件转换为android。在IOS中有这样一个插件调用

cordova.exec('InAppPurchaseManager.requestProductsData', callbackName, {productIds: productIds});
这行代码使用本机层从iTunes商店获取产品详细信息。一旦将此消息发送到本机层,它就会发出异步请求以获取产品详细信息。一旦收到产品,它就会发出调用

NSString *js = [NSString stringWithFormat:@"%@.apply(plugins.inAppPurchaseManager, %@);", callback, [callbackArgs cdvjk_JSONSerialize]];
    [command writeJavascript: js];
在上行中,变量callback保存调用插件时参数callbackName传递的值。我如何在安卓系统中实现同样的功能

该插件没有在android中接收callbackname值的选项

public PluginResult execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException
在phonegap的android中,我使用的是这种方法

cordova.exec(callbackName, null, "MyPluginClass", "getProducts", productIds);
我如何在android中实现同样的功能


谢谢

您必须使用Google Play Stores应用内计费服务。GitHub上的这个项目有一些很好的例子:

我没有时间自己为IOS和Android创建一个代码库,但我计划将来。。。我最后做的是,添加一个单独的层可能会更快,但我当时只是想让它工作起来,并在将来进行重构。。。我是这样做的,对Android GitHub项目的修改最少:

           if ( window.plugins.InAppPurchasePlugin ) {

            // launch the ios in app purchase MakePurchase function....
            var quantity = 1;

            window.plugins.InAppPurchasePlugin.buyProduct( config.gratitudeIosInAppProductId, quantity, buyProductError );
        }
        else {

            if ( window.plugins.inappbilling ) {

                window.plugins.inappbilling.buy( androidBuySuccessHandler, buyProductError, config.gratitudeAndroidInAppProductId );
            }
            else {

                kendoConsole.log( 'no inappbilling?' );
            }
        }

嗨,谢谢你的回复。我在ap账单服务中使用谷歌。但我试图重用phonegap当前源代码中存在的回调,以避免更多的编码。你知道android如何接收回调参数吗?