在app中购买诺基亚X市场应用程序

时间:2014-04-03 07:35:12

标签: android in-app-purchase in-app-billing nokia nokiax

我为诺基亚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显示。所以它的意思是服务连接没有连接。我在清单中给出账单许可。请帮助我,为什么我得不到正确的结果。

1 个答案:

答案 0 :(得分:1)

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

BR, 的Janne

相关问题