1

我为诺基亚 X、诺基亚 X+ 和诺基亚 XL 制作安卓游戏。我想在我的应用程序中添加应用程序购买。我尝试了很多方法,但它对我不起作用。请看下面的代码。我从 onCreate 方法调用此代码。

    //Verify In-App Payment enabler SHA1 fingerprint. 
    Intent paymentEnabler = new Intent("com.nokia.payment.iapenabler.InAppBillingService.BIND");
    paymentEnabler.setPackage("com.nokia.payment.iapenabler"); 
    bindService(paymentEnabler, mServiceConnection, Context.BIND_AUTO_CREATE);

mServiceConnection 的代码如下:

ServiceConnection mServiceConnection = new ServiceConnection() {

@Override
public void onServiceDisconnected(ComponentName name) {
    Toast.makeText(getApplicationContext(), "disconnect", Toast.LENGTH_LONG).show();
    mService = null;
}

@Override
public void onServiceConnected(ComponentName name, IBinder service) {
    mService = INokiaIAPService.Stub.asInterface(service);
    if (isBillingSupported()) {
        Bundle productMappings = new Bundle(); 
        productMappings.putString("1023608", "com.testapp.sword");
        productMappings.putString("1023609", "com.testapp.mighty_sword");
        productMappings.putString("1023610", "com.testapp.axe");
        Toast.makeText(getApplicationContext(), "support billing", Toast.LENGTH_LONG).show();

        try {
            mService.setProductMappings(3, getPackageName(), productMappings);
            Toast.makeText(getApplicationContext(), "support billing work", Toast.LENGTH_LONG).show();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }else {
        Toast.makeText(getApplicationContext(), "support not billing", Toast.LENGTH_LONG).show();
    }
}

}; 这段代码对我不起作用。没有显示 Toast。所以这意味着服务连接没有连接。我在清单中给予计费许可。请帮助我为什么我没有得到正确的结果。

4

1 回答 1

1

您确定您是在诺基亚 X 模拟器或真实设备中运行该代码吗?如果支付启动器存在,它应该绑定到服务。如果您在模拟器中运行,请确保您的 AVD 目标是诺基亚 X 系统映像(您可以看到诺基亚风格的 UI)。

兄弟,珍妮

于 2014-04-03T13:22:27.537 回答